
Before you can add a Samba user, the user account needs to exist. On a Linux system, the useradd command can be used to create the user account.
useradd -p itsasecret -d /home/john.doe -s /bin/bash john.doe
Then the smbpasswd -a command can be used to create the Samba user.
~]# smbpasswd -a john.doe
New SMB password:
Retype new SMB password:
Added user john.doe.
Or the following can be done to pass the password in on the command line.
(echo itsasecret; echo itsasecret) | smbpasswd -a -s john.doe
If Samba is configured to use the tdbsam backed and you do not have "smb passwd file" defined in your smb.conf file, this will create a file named passdb.tdb at /var/lib/samba/private.
~]# ll /var/lib/samba/private/
drwx------. 2 root root 4096 Oct 17 05:16 msg.sock
-rw-------. 1 root root 421888 Oct 17 05:16 passdb.tdb
-rw-------. 1 root root 430080 Nov 11 2019 secrets.tdb
If Samba is configured to use the smbpasswd backed and you do not have "smb passwd file" defined in your smb.conf file, this will create a file named smb.passwd at /var/lib/samba/private.
~]# ll /var/lib/samba/private/
drwx------. 2 root root 4096 Oct 17 05:16 msg.sock
-rw-------. 1 root root 421888 Oct 17 05:16 smb.passwd
-rw-------. 1 root root 430080 Nov 11 2019 secrets.tdb
Or, you may want to define the location of the file in your smb.conf file.
smb passwd file = /etc/samba/smb.passwd
Did you find this article helpful?
If so, consider buying me a coffee over at