Sign up ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I installed samba on my server and I am trying to write a script to spare me the two steps to add user, e.g.:

adduser username
smbpasswd -a username

My smb.conf states:

# 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

Further reading brought me to pdbedit man page which states:

   -a     This option is used to add a user into the database.  This  com-
          mand needs a user name specified with the -u switch. When adding
          a new user, pdbedit will also ask for the password to be used.

          Example: pdbedit -a -u sorce
          new password:
          retype new password


          pdbedit does not call the unix password syncronisation script if
          unix password sync has been set. It only updates the data in the
          Samba user database.

          If you wish to add a user and synchronise the password that  im-
          mediately, use smbpasswd’s -a option.

So... now I decided to try adding a user with smbpasswd:

1st try, unix user still does not exist:

root@raspberrypi:/home/pi# smbpasswd -a newuser
New SMB password:
Retype new SMB password:
Failed to add entry for user newuser.

2nd try, unix user exists:

root@raspberrypi:/home/pi# useradd mag
root@raspberrypi:/home/pi# smbpasswd -a mag
New SMB password:
Retype new SMB password:
Added user mag.
# switch to user pi, and try to switch to mag
root@raspberrypi:/home/pi# su pi
pi@raspberrypi ~ $ su mag
su: Authentication failure

So, now I am asking myself:

  1. how do I make samba passwords sync with unix passwords?
  2. where are samba passwords stored?

Can someone help enlighten me?

share|improve this question
The passwords are stored within the databases in /var/lib/samba/, I believe passwords are in secrets.tdb but I am not certain. As for your former question, I doubt there is an easy way. – Zoredache Sep 23 '12 at 8:05
@Zoredache, well, that is helping also. I think I found a solution, but I am still testing it. – Oz123 Sep 23 '12 at 8:14

1 Answer 1

up vote 5 down vote accepted

Well... the missing link was:


So, after installing this packages it works as expected. The Internet's long term memory just brings partial information sometimes. So in order to fight this I am publishing here the correct link how to sync samba passwords with unix passwords, and also my own test.

root@raspberrypi:/home/pi# passwd mag2
passwd: user 'mag2' does not exist
root@raspberrypi:/home/pi# useradd mag2
root@raspberrypi:/home/pi# echo "mag2:12345" | chpasswd
root@raspberrypi:/home/pi# smbclient -L localhost -U mag2
Enter mag2's password: 
Domain=[WORKGROUP] OS=[Unix] Server=[Samba 3.6.6]

    Sharename       Type      Comment
    ---------       ----      -------
    print$          Disk      Printer Drivers
    IPC$            IPC       IPC Service (raspberrypi server)
Domain=[WORKGROUP] OS=[Unix] Server=[Samba 3.6.6]

    Server               Comment
    ---------            -------
    RASPBERRYPI          raspberrypi server

    Workgroup            Master
    ---------            -------
root@raspberrypi:/home/pi# su pi
pi@raspberrypi ~ $ su mag2
Added user mag2.


I hope this helps someone else.

share|improve this answer
Link is broken, that is why we put valuable info in the answer :/ – ubiquibacon Apr 19 '14 at 17:38

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.