Assign default password to new users in Solaris

Hi All,

I am working on a Solaris 10 machine and now working with a user creation script. I want to create users using the script and assign a default password.

I found the use of 'expect' in one post, but 'expect' is not available in our server.

Also, the below code is not working for me.

# useradd -m -d /home/foo foo
# echo "foo" | passwd --stdin foo
Changing password for user foo.
passwd: all authentication tokens updated successfully.

Now I am thinking of editing the /etc/shadow file with the password string of other user. But I am really afraid to try this way as our servers are live having 100+ users. can anyone suggest if editing the /etc/shadow file using the below 'sed' command will work?

passwd=crypted_passwd 
sed "s/${name}/${name}:${passwd}/" /etc/shadow > /tmp/shadow.tmp 
cp /tmp/shadow.tmp /etc/shadow 
rm /tmp/shadow.tmp 

Or Can you help me with a new way of doing it?

Thanks in advance.
Jaise

hi,
have a look at man usermod, the section OPTIONS, option -p.

perform tests on a test account

see ya
fra

1 Like

Hi Frappa,

Thanks for your reply.

I couldn't find a '-p' switch for 'usermod' neither in 'man' nor in practical.
Any other way comes to your mind!!?

Regards,
Jaise