while true
do
read username passwd
if [ "$username" == "" ]
then
exit
fi
passwd_hash=$(openssl passwd $passwd)
echo "Using the following password hash for user "$username": $passwd_hash"
/usr/sbin/useradd $username -p "$passwd_hash";
done
do
read username passwd
if [ "$username" == "" ]
then
exit
fi
passwd_hash=$(openssl passwd $passwd)
echo "Using the following password hash for user "$username": $passwd_hash"
/usr/sbin/useradd $username -p "$passwd_hash";
done
use the script like this:
add_multiple_users.sh < /path/to/userlist.txt
Don't forget to make the script executable:
chmod +x add_multiple_users.sh
On Mon, Aug 3, 2009 at 2:56 PM, nate <centos@xxxxxxxxxxxxxxxx> wrote:
David Leon wrote:from 'man passwd'
> I'm trying to avoid typing every password manually. I just need an
> script that makes the job.
>
> useradd creates the account but still need to setup accpunt's password.
>
--stdin
This option is used to indicate that passwd should read the
new password from standard input, which can be a pipe.
_______________________________________________
CentOS mailing list
CentOS@xxxxxxxxxx
http://lists.centos.org/mailman/listinfo/centos
_______________________________________________ CentOS mailing list CentOS@xxxxxxxxxx http://lists.centos.org/mailman/listinfo/centos