Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: How to use MD5?

by no_slogan (Deacon)
on Sep 18, 2002 at 00:25 UTC ( #198694=note: print w/replies, xml ) Need Help??


in reply to How to use MD5?

Here's an older node of mine that might help you get started md5-crypting passwds.

Replies are listed 'Best First'.
Re: Re: How to use MD5?
by Anonymous Monk on Sep 18, 2002 at 14:29 UTC
    Mdillon: the exact purpose of this is to create a user using adduser bob -p $encrypass as the command, run from a perl script. i'm stuck :-(
      First, you need to generate an appropriate salt. The code provided by tadman in this node should work.

      Then, either install Crypt::PasswdMD5 and use:

      use Crypt::PasswdMD5; my $crypted = unix_md5_crypt $passwd, $salt;
      Or, since you're apparently using RedHat (since adduser is a RedHat-specific command AFAIK) and your libc's crypt should do MD5-crypt automatically given a proper MD5 salt, use: my $crypted = crypt $passwd, $salt; To make sure this works, print the value of $crypt; it should be something like $1$b1yv9grF$mpwoS2r11VtENFrAmF2WW/ (instead of the shorter string returned by traditional DES-crypt). Once you've confirmed that you have what looks like an MD5-crypted password, use the value of $crypted in your command line:
      system("adduser", "bob", "-p", $crypted) == 0 or die "Error adding user 'bob': $!$/";
      The secret to getting crypt to work correctly is in providing a salt starting with '$1$' and having 8 characters (instead of the normal 2 used for DES-crypt). There are similar conventions for using other crypt variants (e.g. '$2$' for SHA-crypt).

      my  man adduser says:

      -p passwd The encrypted password, as returned by crypt(3). The default is to disable the account.

      That is, unless you use a modified adduser, you have to provide a crupt'ed password (not md5).

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://198694]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (2)
As of 2021-05-11 23:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Perl 7 will be out ...





    Results (123 votes). Check out past polls.

    Notices?