27

Exact same question as Create a user for sharing purposes only 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.

Foo Bar
  • 443

2 Answers2

62
  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.
mikewhatever
  • 33,013
8

With Active Directory (Samba 4.0+)

If you have Samba 4.x and it is connected to an Active Directory, you can use samba-tool to add a user to it:

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
Paul
  • 707