On Sun, 09 Nov 2003 10:41:30 -0800, [EMAIL PROTECTED] muttered: > Hello. > > What command(s) should I use in order to > add a new user to my system (from a bash > script) and specify a default (not null) > password for this user? > > I see that the command "useradd" does have > the "-p passwd" option, but the "passwd" > should be encrypted, as returned by crypt(3). > Then how can I obtain the encrypted password? > > Any clues?
Two possible solutions:
1. don't set a password with useradd; just run passwd after adding the
user
2. set the password for one user, read the crypted password out of
/etc/shadow (as root), then use that as input to useradd -p
3. python script below (call it anything _except_ crypt)
#!/usr/bin/python2.2
import crypt, getpass
hash = crypt.crypt(getpass.default_getpass(), "xy") # << salt
print "Hash:", hash
--
Andrew Farmer
[EMAIL PROTECTED]
pgp00000.pgp
Description: PGP signature
