[CentOS] help - batch account creation

Mon Aug 3 19:35:08 UTC 2009
a arias <aarias239 at gmail.com>

Try this:

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

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 at linuxpowered.net> wrote:

> David Leon wrote:
> > 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.
> >
>
> from 'man passwd'
>
>       --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 at centos.org
> http://lists.centos.org/mailman/listinfo/centos
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.centos.org/pipermail/centos/attachments/20090803/ea20bb2e/attachment-0003.html>