Posted 2011/05/06
Bulk password changes
I recently had to create a batch of new user account under Linux. I already had a nice script for generating a hard password but I needed to set them on mass. Reading man passwd
I found the section about using it in a script:
--stdin This option is used to indicate that passwd should read the new password from standard input, which can be a pipe.
When I tried to use it I got this error:
pass="jjhjhjhg" user="testbob" echo $pass | passwd –-stdin "$user" passwd: Only one user name may be specified.
In the end I found another program to do it for me:
echo "$user:$pass" | chpasswd