Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

MD5 encryption with "useradd" command

Posted on 2002-07-12
8
Medium Priority
?
1,287 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 200 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

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…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

604 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