4 ms·
Batch process creating new users
- memset 15y agoThis 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 15y agoyes 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 15y agoCorrect 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