[Gllug] passwd and creating passwords
Pete Ryland
pdr at accucard.com
Tue Jan 27 17:38:38 UTC 2004
On Tue, Jan 27, 2004 at 04:44:18PM +0000, Jason Clifford wrote:
> On Tue, 27 Jan 2004, Xander D Harkness wrote:
>
> > I would like to add a user using useradd -p hashed-password joe
> >
> > useradd can take a password on the command line but it needs to be a
> > hash ready to be placed in the /etc/shadow file.
> >
> > How can I create the correct md5 hash as none of the man pages are very
> > helpful.
>
> The following perl will do it for you:
>
> my $salt = '$1$';
> $salt .= join '', ('.', '/', 0..9, 'A'..'Z', 'a'..'z')[rand 64, rand 64,
> rand 64, rand 64, rand 64, rand 64, rand 64, rand 64];
> my $pwcrypt = crypt($password, $salt);
>
> They key thing to note is that the salt is $1$ followed by 8 more slat
> characters.
Shouldn't the salt be random?
Pete
--
Gllug mailing list - Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug
More information about the GLLUG
mailing list