useradd and crypt

Michael Hipp Michael
Tue Oct 3 11:31:17 PDT 2006


I've read numerous HOW-TOs that tell me to add users to my system like this:

    useradd -c "Fred Jones" -m -g users -p abc123 fred

But that doesn't do what it appears to do. The '-p' option expects an 
*encrypted* password. If I enter it like above, it puts the plaintext 
"abc123" into /etc/shadow.

The man page says:

    -p passwd  The encrypted password, as returned by crypt(3)

'crypt' is a system call - not exactly something you can use from the 
command line.

So if I want to actually enter:

    useradd -c "Fred Jones" -m -g users -p $ENCRYPTED fred

What do I use to actually get an encrypted password from "abc123"?

Thanks,
Michael





More information about the Linux-users mailing list