Previous Section  < Day Day Up >  Next Section

Recipe 23.21. Keeping Samba and Linux Passwords in Sync

23.21.1 Problem

Your Samba users know they can use smbpasswd to change their own passwords, but when they do this, their Linux passwords on the Samba server do not change. You would like a method to keep them synchronized.

23.21.2 Solution

Add these lines to the global section of smb.conf:

unix password sync = yes

passwd program = /usr/bin/passwd %u

passwd chat = "*Enter OLD password*" %o\\n "*Enter NEW password*" %n\\n "*Reenter NEW 

password*" %n\\n "*Password changed*"

This calls passwd to change the users' passwords in /etc/passwd when they change their Samba passwords. passwd chat controls the change process and gives feedback. You can modify this to suit your own needs.

23.21.3 Discussion

This is a one-way trip; it does not update the Samba passwords when users change their Linux passwords.

The macro substitutions used in passwd chat are these:


%u

Username.


%o

Old password.


%n

New password.


\\n

Newline, escaped. This breaks the passwd chat output into separate lines, instead of printing it all on one line.

For a complete list of Samba's substitution macros, see smb.conf(5), in the "Variable Substitutions" section.

23.21.4 See Also

  • smb.conf(5)

    Previous Section  < Day Day Up >  Next Section