17

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.

4
  • 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
41
  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.
5
  • 6
    --no-create-home --disabled-password --disabled-login This saved my day! Still helpful in 2017! – Stan Dec 5 '17 at 11:39
  • 2
    @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
  • how can I do first step on centos? – Sollosa Mar 11 '19 at 11:03
  • maybe better: sudo adduser --no-create-home --disabled-password --disabled-login --gecos "" sambausername (where --gecos "" option to skip the chfn interactive part askubuntu.com/a/94067/828892 and uid < 1000 for hidden account askubuntu.com/a/22010/828892) – ajcg Nov 12 '19 at 21:10
7

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 (if it is connected to another authentication source, like Active Directory).

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
6
  • Should this be the new accepted answer? – Pichan Feb 22 '17 at 12:59
  • 1
    Scratch that. Didn't work after all :/ Seems that samba-tool is for Active Directory. – Pichan Feb 22 '17 at 13:02
  • 3
    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
  • 2
    samba-tool is for Active Directory (AC) provisioning only askubuntu.com/a/490342/828892 – ajcg Nov 11 '19 at 22:06

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.