[–] memset 14y ago ↗ 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 14y ago ↗ 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 fooworking example for the site:cat newusers | while read u p ndouseradd --comment "$n" --password $(python -c 'import crypt; import os; print crypt.crypt(os.environ.get("p", ""),"salt")') --create-home $udoneCouldn't get it work with perl:) [–] 5partan 14y ago ↗ Correct Version:cat newusers | while read u p ndoexport puseradd --comment "$n" --password $(python -c 'import crypt; import os; print crypt.crypt(os.environ.get("p", ""),"salt")') --create-home $udone [–] memset 14y ago ↗ Hey, this worked! Thank you so much :) [–] 5partan 14y ago ↗ You are welcome :)
[–] 5partan 14y ago ↗ Correct Version:cat newusers | while read u p ndoexport puseradd --comment "$n" --password $(python -c 'import crypt; import os; print crypt.crypt(os.environ.get("p", ""),"salt")') --create-home $udone [–] memset 14y ago ↗ Hey, this worked! Thank you so much :) [–] 5partan 14y ago ↗ You are welcome :)
5 comments
[ 4.4 ms ] story [ 18.4 ms ] threadperl -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:)
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