I am writing a script to copy the linux user passwords to samba on ubuntu server 10.04. I am using samba 3 with tdbsam backend.
1) How do I (if possible) copy accounts (user/password) from linux to samba using a shell script?
2) How do I find out in my script if a certain user is in the samba user db and has a password and is activated? I need this as my script is run more often and on subsequent runs I would need to find out if the user is already present. I would not copy or set password or activate if unneccesary.
This is the head of my config:
[global] workgroup = WORKGROUP server string = %h server security = SHARE obey pam restrictions = Yes pam password change = no passdb backend = tdbsam unix password sync = no syslog = 0 log file = /var/log/samba/log.%m max log size = 1000 dns proxy = No panic action = /usr/share/samba/panic-action %d encrypt passwords = true invalid users = root hosts allow = 192.168.0.1/24
The samba password file and your system shadow files have different hashing schemes. I believe neither of them is reversible, so there’s no way to convert between one and the other. The only way to synchronize the passwords is at the time they are changed by updating both files simultaneously from the user’s input. That’s the whole point of the unix password sync setting .