Re: [Hampshire] [OT] Linux compatible crypt(3) password from…

Top Page

Reply to this message
Author: Simon Reap
Date:  
To: lug, Hampshire LUG Discussion List
Subject: Re: [Hampshire] [OT] Linux compatible crypt(3) password from Perl
Damian Brasher wrote:
> I am writing subroutine to generate a Linux compatible password for the
> command useradd executed from within a Perl script, where useradd can be
> supplied a compatible encrytped password as with crypt(3) generated
> passwords. I need something like this:
>

If your /etc/shadow has passwords like
    $1$abdef$7Jtzy.MmT50duhCix.rlv0
then it is using MD5 passwords rather than the DES ones which "crypt" 
defaults to.  For this, the salt in crypt must start "$1$" followed by 
up to eight characters and an optional trailing "$" e.g.:
    $fred=crypt "HelloMum","\$1\$abcdef";
    print "$fred\n"
On my eeePc, this returns the above password.


Simon