Solved

MD5 encryption with "useradd" command

Posted on 2002-07-12
8
1,261 Views
Last Modified: 2008-03-17
Hi,

I have Linux 7.1 installed with MD5 enabled.
when I type:
$> useradd -g popusers -p THEPASS USERNAME

The user USERNAME is created. But The /etc/shadow file contains THEPASS as I typed it (Not encrypted)!!!

I would like to have the passwords from command line automatically MD5 incrypted without using the passwd utility.

Thanks
0
Comment
Question by:Curieux
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 5

Expert Comment

by:arvind
ID: 7151065
Only passwd command can encrypt the text to MD5. I think u need use passwd for password. By the way why you like to give passwd in the useradd command. Ar u want to create bulk users?
0
 
LVL 3

Expert Comment

by:cincin77
ID: 7153724
by using the -p option of useradd, you mean that the encrypted state of the password is what you write.
0
 
LVL 40

Accepted Solution

by:
jlevie earned 50 total points
ID: 7155163
As pointed out, the useradd command requires that you specify the encrypted password (MD5 in this case). An easy way to generate such a password is with a small Perl script. To use it you'll need to get and install the Crypt::PasswdMD5 module.

Save what's below into a file named md5passwd, make it executable (chmod +x md5passwd) and execute it with ./md5passwd <your-passwd>. The result will be printed on STDOUT.

#!/usr/bin/perl
#
# NAME
#       md5passwd - generate an MD5 encrypted password
#
# SYNOPSIS
#       md5passwd password
#
# DESCRPTION
#       Encrypts the specified password with MD5 in a manner suitable for use
#       in a Linux passwd/shadow file.
#
#       This code requires the CPAN Crypt-PasswdMD5-1.2.tar.gz (or later) Perl
#       module to be installed, which you can get from http://www.perl.com/CPAN
#
# Author: Jim Levie (jim@entrophy-free.net)
#
use Crypt::PasswdMD5;

if($#ARGV != 0)
{
  print "usage - md5passwd password\n\n";
  exit(1);
}

@range = (qw(. /), '0'..'9','a'..'z','A'..'Z');

$salt = join '', map $range[rand $x], 1..shift||1;

$epw = unix_md5_crypt($pw, $salt);
print "$epw\n";
exit(0);
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 51

Expert Comment

by:ahoffmann
ID: 7155747
listening ..
0
 

Expert Comment

by:CleanupPing
ID: 9078459
Curieux:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0
 
LVL 3

Expert Comment

by:cincin77
ID: 9078484
I do agree with my comment...
0
 
LVL 12

Expert Comment

by:paullamhkg
ID: 10020057
No comment has been added lately, so it's time to clean up this TA.
I will leave the following recommendation for this question in the Cleanup topic area:

Accept: jlevie {http:#7155163}

Please leave any comments here within the next seven days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

paullamhkg
EE Cleanup Volunteer
0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I have seen several blogs and forum entries elsewhere state that because NTFS volumes do not support linux ownership or permissions, they cannot be used for anonymous ftp upload through the vsftpd program.   IT can be done and here's how to get i…
Note: for this to work properly you need to use a Cross-Over network cable. 1. Connect both servers S1 and S2 on the second network slots respectively. Note that you can use the 1st slots but usually these would be occupied by the Service Provide…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

697 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question