2

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

2 Answers 2

0

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 .

1
  • thank you. i have to give up on question 1 then. but would still be interesting to find out if a user is in the tdbsam and active or not by a script.
    – user12096
    Jan 27, 2010 at 1:32
0

I decided to switch back to smbpasswd for now. And I decided not to sync passwords. I need a simple solutions that just works here now.

This is the head of the config now:

[global]
         workgroup = WORKGROUP
         security = SHARE
         passdb backend = smbpasswd:/etc/samba/smbpasswd   
         unix password sync = no
         syslog = 0
         log file = /var/log/samba/log.%m
         max log size = 1000

And this is the script I will be running on initial install and from time to time:

USER=samwin                           
cat /etc/samba/smbpasswd | grep -e "^$USER:" 
if [ $? -ne 0 ]; then       
  echo "Adding Samba user USER:"  
  smbpasswd -a $USER 
else               
  echo "Samba user $USER already present." 
fi

I am still curious for the answer of my question above for future installs and I will accept the answer that fits best.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .