Add new user with a specif password in script

John Kodis kodis at mail630.gsfc.nasa.gov
Sun Nov 9 19:05:02 UTC 2003


On Sun, Nov 09, 2003 at 04:41:30PM -0200, romildo at uber.com.br wrote:

> 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?

$ perl -e 'print crypt("password", "salt") . "\n"'
sa3tHJ3/KuYvI

> Any clues?

# useradd joe; echo password | passwd --stdin joe

This has the advantage that joe will get an md5 password hash rather
than a less secure crypted one.

-- 
John Kodis                                    Goddard Space Flight Center
kodis at mail630.gsfc.nasa.gov                      Greenbelt, Maryland, USA
Phone: 301-286-7376                                     Fax: 301-286-1771





More information about the fedora-list mailing list