Is it possible to tie your login password to your samba password?

Ideally every 30 days, users need to change their passwords to login into the machine and if its possible, when they update their password, it'll also update the samba password.


I believe Samba is configured like that by default, here are the relevant lines in smb.conf:

# "security = user" is always a good idea. This will require a Unix account
# in this server for every user accessing the server. See
# /usr/share/doc/samba-doc/htmldocs/Samba3-HOWTO/ServerType.html
# in the samba-doc package for details.
    security = user


# This boolean parameter controls whether Samba attempts to sync the Unix
# password with the SMB password when the encrypted SMB password in the
# passdb is changed.
    unix password sync = yes

More info on these options and more here. Hope that helps.


The first time you add a linux user (adduser) you need to add them to smbpasswd as well.

sudo smbpasswd -a <user>

when prompted for a password use the same password you used with adduser. After this the smb password should be updated automatically when you change the linux password with sudo passwd <user>

  • Well not so fast. So I have the security = user uncommented, same with the unix password sync but when I go to add a user, it keeps asking for a password. Am I to enter my login password here? – Muhnamana Jun 21 '12 at 3:09
  • If you add a user to the system (sudo adduser kevin for example) you need to give them a password as well, this is the password that will be required for that user to access a share. Change password with sudo passwd kevin. Does that help? – jpetersen Jun 21 '12 at 3:58
  • What if I already have a user added to the system, in this case "Family". Samba is up and running and while trying to connect via my Mac or Win7 box, once I enter my login credentials for "Family", a message pops up saying invalid username or I don't have access. I'm guessing I am missing something within the config somewhere. – Muhnamana Jun 21 '12 at 12:22
  • Are you restarting the samba services after making changes to the config file? Do you have valid users = Family in smb.conf under the share section? If your still having trouble it might be best to start another question with more detail: smbd error messages that pop up in /var/log/auth.log, and how you set up samba possibly with the dump of your config file as well testparm /etc/samba/smb.conf....(which also tests smb.conf syntax). – jpetersen Jun 21 '12 at 17:44
  • Ok, well this might sound odd, but how do I create a unix username? I'm currently logged into ubuntu with the "family" username, with a password of 12345. I ran the following command to see what users have been added: sudo pdbedit -L -v and the only user added is "nobody". So should I run sudo smbpasswd -a family? If so, what password should I enter? Should I enter 12345, same as my logon? – Muhnamana Jun 22 '12 at 0:40

To have your updated unix password also be your new samba password, you'll have to install the libpam-smbpass package.

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.