PDA

View Full Version : HOWTO :: Mass create users and assign them with default passwords


royong
26-04-2006, 17:40
Source file contains a single line entry for each user in the format of username,password
# vi mynewusers
jane,123456
peter,password
paul,654321
john,qwerty
The following is the script that will perform the actual work
# vi mycreatenewsers.sh
sourcefile=mynewusers
users=`cat $sourcefile | cut -f1 -d,`
for virtualuser in $users
do
virtualpassword=`cat $sourcefile | grep $virtualuser | cut -f2 -d,`
echo "$virtualpassword" | passwd --stdin $virtualuser
echo "$virtualuser has been successfully added with password of $virtualpassword"
done
Perform the following command to run the script
# sh ./mycreatenewusers.sh