{"id":541,"date":"2011-01-28T00:30:38","date_gmt":"2011-12-19T05:51:50","guid":{"rendered":"http:\/\/kraftek.com\/blog\/configure-samba-with-users-and-groups\/"},"modified":"2011-01-28T00:30:38","modified_gmt":"2011-12-19T05:51:50","slug":"configure-samba-with-users-and-groups","status":"publish","type":"post","link":"\/blog\/index.php\/configure-samba-with-users-and-groups\/","title":{"rendered":"Configure samba with users and groups"},"content":{"rendered":"<p>I needed to share several directories with write permissions to some people and read permissions to others, so I had to<br \/>\ncreate all the necessary infrastructure for samba to work.<br \/>\nYou have to create unix users and groups to later map them to samba users and groups.<br \/>\nIn order to make this work with w95,w98, wxp, and w2k, I needed to use exactly the same usernames the people have<br \/>\nin their machines.<br \/>\nSo, if, to say, Bob signs in his machine with the user bobd, i need to create bobd in my samba server, as a unix account,<br \/>\nand then map it to a smb user. The password is not going to be the same as his windows password, this would require<br \/>\njoining the windows NT\/NT4 domain.<br \/>\nSaid that, we proceed to create the groups and users like this<br \/>\n# groupadd infra<br \/>\n# useradd -m -d \/home\/rdircio -g infra rdircio<br \/>\n# passwd rdircio<br \/>\nThen, to add the users in samba<br \/>\n# smbpasswd -a rdircio<br \/>\nTo map the unix groups we need to do<br \/>\n# net groupmap add ntgroup=&#8221;infra&#8221; unixgroup=infra type=d<br \/>\nAfter this, created the shared directories,inside \/shared ending up like this<br \/>\ndrwxrwxr-x 2 root infra 48 2006-01-03 12:20 cambios\/<br \/>\ndrwxr-xr-x 2 luis infra 48 2006-01-03 12:51 diagramas\/<br \/>\ndrwxrwxr-x 2 root infra 48 2006-01-03 12:17 inventario\/<br \/>\ndrwxrwxr-x 6 root inversion 240 2006-01-03 12:30 inversion\/<br \/>\ndrwxrwxr-x 10 root infra 280 2006-01-03 12:27 ismas\/<br \/>\ndrwxrwxr-x 5 root infra 152 2006-01-04 07:35 mantenimiento\/<br \/>\ndrwxrwxr-x 2 ppispma1 root 48 2006-01-03 09:47 publico\/<br \/>\nyou can see the permissions attached to specific users and groups, so read\/write permission is achieved.<br \/>\nthe smb.conf corresponding to this is:<br \/>\n[global]<br \/>\nworkgroup = INFRA<br \/>\nserver string = INFRA UNIX<br \/>\nsecurity = SHARE<br \/>\n[mp3]<br \/>\ncomment = musica<br \/>\n283\/433<br \/>\npath = \/mp3<br \/>\nread only = No<br \/>\nguest ok = Yes<br \/>\n[inversion ]<br \/>\nwriteable = yes<br \/>\nread list = @infra<br \/>\nwrite list = @inversion<br \/>\npath = \/shared\/inversion<br \/>\ncomment = Proyectos de Inversion<br \/>\nvalid users = @infra<br \/>\npublic = yes<br \/>\n[ inventario ]<br \/>\nwriteable = yes<br \/>\nread list = @infra<br \/>\nwrite list = @infra<br \/>\npath = \/shared\/inventario<br \/>\ncomment = Informacion de Infraestructura<br \/>\nvalid users = @infra<br \/>\npublic = yes<br \/>\n[ mantto ]<br \/>\nread list = @infra<br \/>\nwriteable = yes<br \/>\npath = \/shared\/mantenimiento<br \/>\nwrite list = @infra<br \/>\ncomment = Informacion de Infraestructura<br \/>\nvalid users = @infra<br \/>\npublic = yes<br \/>\ncreate mode = 775<br \/>\ndirectory mode = 775<br \/>\n[ info general ]<br \/>\nwriteable = yes<br \/>\nread list = @infra<br \/>\nadmin users = ppispma1<br \/>\nwrite list = ppispma1<br \/>\npath = \/shared\/publico<br \/>\ncomment = Informacion de Infraestructura<br \/>\nvalid users = @infra<br \/>\npublic = yes<br \/>\n[ cambios ]<br \/>\nwriteable = yes<br \/>\nread list = @infra<br \/>\nwrite list = @infra<br \/>\npath = \/shared\/cambios<br \/>\ncomment = Informacion de Infraestructura<br \/>\nvalid users = @infra<br \/>\npublic = yes<br \/>\n284\/433<br \/>\n[ ismas ]<br \/>\nwriteable = yes<br \/>\nread list = @infra<br \/>\nwrite list = @infra<br \/>\npath = \/shared\/ismas<br \/>\ncomment = Informacion de Infraestructura<br \/>\nvalid users = @infra<br \/>\npublic = yes<br \/>\n[ homes ]<br \/>\nwriteable = yes<br \/>\nread list = @infra<br \/>\nwrite list = @infra<br \/>\npath = \/home<br \/>\ncomment = Informacion de Infraestructura<br \/>\nvalid users = @infra<br \/>\npublic = yes<br \/>\n[my home]<br \/>\ncomment=%u home dir<br \/>\npath=\/home\/%u<br \/>\nwriteable = yes<br \/>\nread list = @infra<br \/>\nwrite list = @infra<br \/>\ncomment = homes<br \/>\nvalid users = @infra<br \/>\npublic = yes<br \/>\nThe first share is totally public, anyone can enter, but the others require password.<br \/>\nWe can avoid using different passwords for samba and unix users using pam_smbpass, we&#8217;ll discuss how to<br \/>\ndo this later<br \/>\n285\/433<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I needed to share several directories with write permissions to some people and read permissions to others, so I had to create all the necessary infrastructure for samba to work. You have to create unix users and groups to later map them to samba users and groups. In order to make this work with w95,w98, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-541","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"\/blog\/index.php\/wp-json\/wp\/v2\/posts\/541","targetHints":{"allow":["GET"]}}],"collection":[{"href":"\/blog\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"\/blog\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"\/blog\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"\/blog\/index.php\/wp-json\/wp\/v2\/comments?post=541"}],"version-history":[{"count":0,"href":"\/blog\/index.php\/wp-json\/wp\/v2\/posts\/541\/revisions"}],"wp:attachment":[{"href":"\/blog\/index.php\/wp-json\/wp\/v2\/media?parent=541"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"\/blog\/index.php\/wp-json\/wp\/v2\/categories?post=541"},{"taxonomy":"post_tag","embeddable":true,"href":"\/blog\/index.php\/wp-json\/wp\/v2\/tags?post=541"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}