This is a read-only archive. Find the latest Linux articles, documentation, and answers at the new!

Automated user management with Expect

Posted by: Anonymous [ip:] on September 26, 2007 01:14 PM
Using a spreadsheet is fine, but don't generate passwords in the spreadsheet. This is a "smoking gun", and the "random" number generator in your spreadsheet is not very random.

Instead, you can use the "mkpasswd" command. And it combines nicely with the --stdin option on the passwd command. Here is the bits of the script I use to do it:



PASSWORD=`mkpasswd -s 0`
echo "$PASSWORD" | /usr/bin/passwd --stdin $USERID

/usr/sbin/sendmail -oi -t <<EOF
To: $USERID <$>
From: System Adminstrator <>
Subject: Your new password

An account has been created for you:
Username: $USERID
Password: $PASSWORD



Return to Automated user management with Expect