I'd like to set up my samba so that each user has access to specific folders. Some of them for example have home folder on server and those should have access to their home folder, other don't and they shouldn't. I have set

    valid users = user1, user2
    #those users have access to this share

The result is that only some users have access to those folders, that is good. But when I log as user3 he sees this share1, but cannot access it. How can I make it visible only to some users, so that users that cannot access share don't see it at all?

I have found some suggestions to use browseable list = user1 user2 but it doesn't work for me, testparm says that browseable list is incorrect.


What you want seems to only be possible via an ugly hack.

First set the share to browseable = no and include /etc/samba/sharename.%U.conf.

path = /path/to/share
valid users = user1, user2 
public = no
browseable = no
writeable = yes
include = /etc/samba/sharename.%U.conf

The following lines are then put in the files /etc/samba/sharename.user1.conf and /etc/samba/sharename.user2.conf. Of course, only one of these need exist as a regular file, the other can be a symlink.

browseable = yes

Note, however, the definition of %U in man smb.conf:

       session username (the username that the client wanted, not
       necessarily the same as the one they got).

If I'm reading this correctly, it implies that anyone using smbclient (or other CIFS tool that allows the user to specify the username) can "browse" the share with the -U user1 or -U user2 options, without needing the password.

  • Your hack generally works, but doesn't for home directories. I guess I will have to handle them individually – fulaphex Nov 28 '15 at 2:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.