“smbpasswd” for Samba Configuration file at Custom Directory Location

For security reasons or to meet your organizational standards you might have configured samba at your own custom directory location. To provide access to Samba shares for users, you may use of the security modes; user, share, domain, ADS, server. If you are using the “user” security mode, all the passwords of samba users will be stored locally inside the file smbpasswd. Here we will see how to add new user to samba configured at custom directory location.

For default samba configuration, smbpasswd file will be stored under /etc/samba/private/ directory, or else you can see the file location inside the samba configuration file with the following command.

testparm -s -v <path_to_smb.conf_file> | grep passwd

Under global section, you will see an attribute named “smb passwd file“. It is the attribute that sets path to smbpasswd file. Here is an example:

    security = user
    encrypt passwords = yes
    smb passwd file = /usr/local/samba/private/smbpasswd

Now to add new user to access any of the configured samba shares, all you have to do is to add the customized smb.conf file with -c flag to smbpasswd command. Here is an example:

smbpasswd -c <path_to_smb.conf_file> -a <user>

New SMB password: <Enter the new password> [Enter]
Retype new SMB password: <Retype the same password again> [Enter]

Now, you can verify the user addition as below:

grep <user> <path_to_smbpasswd_file>

If the user is added to the file, you will see user name with encrypted password as an output of the above command. If you have any queries on this, you can drop a comment below.

Be the first to comment on "“smbpasswd” for Samba Configuration file at Custom Directory Location"

Leave a comment

Your email address will not be published.