
Batch process creating new users - 5partan
http://tuxradar.com/answers/492
======
memset
This article cites using `pwcrypt` to return the password, and that doesn't
seem to be easily available (at least, not in Ubuntu 10.04.) Is there an
alternative command-line interface to the crypt() function?

------
5partan
yes there is:

perl -e 'print crypt("password", "salt")

so you would do something like:

useradd -d / -g users -p $(perl -e'print crypt("foo", "aa")') -M -N foo

working example for the site:

cat newusers | while read u p n

do

useradd --comment "$n" --password $(python -c 'import crypt; import os; print
crypt.crypt(os.environ.get("p", ""),"salt")') --create-home $u

done

Couldn't get it work with perl:)

~~~
5partan
Correct Version:

cat newusers | while read u p n

do

export p

useradd --comment "$n" --password $(python -c 'import crypt; import os; print
crypt.crypt(os.environ.get("p", ""),"salt")') --create-home $u

done

~~~
memset
Hey, this worked! Thank you so much :)

~~~
5partan
You are welcome :)

