11

Exact same question as this one, but using CLI instead of GUI.

I'd like to allow login access to a shared SMB directory, but the users get no other access to the server.

  • The question you refer to deals with guest access to samba, in other words everyone on the network has access to the share with no password. In your case, if that's what you want, what's the point of creating a special "user for samba only", if all have access anyway? – mikewhatever Oct 14 '14 at 15:04
  • As the other asker also said, I do want logins and passwords for the file share. – Foo Bar Oct 14 '14 at 15:05
  • Not sure what other asker you are talking about. See my answer below, hope it helps. – mikewhatever Oct 14 '14 at 15:19
  • Thanks. I was referring to: askubuntu.com/questions/152020/… – Foo Bar Oct 14 '14 at 16:47
25
  1. Create a user on the server:

sudo adduser --no-create-home --disabled-password --disabled-login sambausername

  1. Add that user to samba (you'll be asked to type a password):

sudo smbpasswd -a sambausername

  1. Create a share by editing /etc/samba/smb.conf. For example, you can add something like this to the bottom:

    [share name]
        comment = whatever
        path = /path to share
        browsable = yes
        read only = no
        guest ok = no
    
  2. Now is a good idea to restart samba:

sudo service smbd force-reload

  1. Go to the client machine and try to access the share with the username and password you've just set up.
  • 3
    --no-create-home --disabled-password --disabled-login This saved my day! Still helpful in 2017! – Stan Dec 5 '17 at 11:39
  • 1
    @Stan Thanks for the feedback, glad it was helpful. – mikewhatever Dec 5 '17 at 15:40
  • How do i use this user as a "valid users = <username>". For some reason this does not work? If i use the username of a user with a dashboard it will work. Otherwise it doesn't. – Myron Oct 4 '18 at 9:44
  • This is beautiful and perfect. Thank you. – spyderdyne Mar 2 at 4:55
  • how can I do first step on centos? – Sollosa Mar 11 at 11:03
5

A Note about adding users on Samba version 4.x

Unlike Samba version 3.x and earlier, Samba version 4.x does not require a local Unix/Linux user for each Samba user that is created. The command is as follows for adding users into Samba Active Directory

samba-tool user add USERNAME-HERE

Please see Samba AD DC howto for more info

Answer Extracted from Cyberciti

To verify your Samba Version just user the command

samba -V

Example Output:

Version 4.3.11-Ubuntu
  • Should this be the new accepted answer? – Pichan Feb 22 '17 at 12:59
  • Scratch that. Didn't work after all :/ Seems that samba-tool is for Active Directory. – Pichan Feb 22 '17 at 13:02
  • 2
    A Futher search shows that you need to config a Samba AD to use this feature. – André M. Faria Feb 22 '17 at 13:18
  • Maybe the AD requirement should be more prominent? – Joril Feb 28 '18 at 10:05
  • In samba 4.7, I'm seeing "samba-tool user add" marked as deprecated. It seems it's now "samba-tool user create" that should be used. I confirm this is working, now as said in previous comments, this is for adding a user to an AD environment, not to a simple SMB file server as asked. – Little Jawa Jul 16 '18 at 11:53

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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