homepage Welcome to WebmasterWorld Guest from 54.166.128.254
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Hardware and OS Related Technologies / Linux, Unix, and *nix like Operating Systems
Forum Library, Charter, Moderators: bakedjake

Linux, Unix, and *nix like Operating Systems Forum

    
batch add *nix users
how to encrypt passwords?
jamie

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 1609 posted 4:00 pm on Dec 9, 2005 (gmt 0)

hi,

setting up a a new server and have a batch of users to add. how do i encrypt the password so that i can use

chpasswd $NAME:$PASS

and have the correct value in /etc/shadow?

many thanks

 

carfo

5+ Year Member



 
Msg#: 1609 posted 4:23 am on Dec 20, 2005 (gmt 0)

man adduser
...
-p passwd
The encrypted password, as returned by crypt(3)
...

That help?

jamie

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 1609 posted 11:48 am on Dec 21, 2005 (gmt 0)

hi carfo,

thanks for replying - i'm afraid i don't quite understand what you mean. on my debian system i have no crypt function?

MattyMoose

10+ Year Member



 
Msg#: 1609 posted 5:50 pm on Dec 29, 2005 (gmt 0)

You do actually have a crypt function, but it's a C function (hence the crypt(3)).

The first trick would be for you to find out what kind of encryption system is standard on your box(es). There are many different types, and it's easy to determine once you look at the shadow files.

These are the standard types of encrypted passwords on *NIX systems and what they look like in a shadow file:

DES/crypt: abJnggxhB/yWI
MD5: $1$L/321sYmS$ygjf8.6wKiHfNF3rir2ca/
Blowfish: $2$
NT-Hash $3$

This is from my FreeBSD system, check your crypt(3) man page for more details on the salt types.

Once you've determined your salt type, which is most likely MD5, you could try to use something like crypt-pw (available at [freshmeat.net...] (Note: you need to build from source with ./configure && make) for crypt, and something that will generate MD5 passwords for you (I tried out https://www.ripe.net/cgi-bin/crypt.cgi briefly ), and there you can generate a test password to try out.

If you don't want to use an online service, you can write your own program that will spit out the MD5 password. Should be straight-forward, and I wrote a quickie Perl program that should do what you need, based on Crypt::PasswdMD5 ( [cpan.uwinnipeg.ca...] )


#!/usr/bin/perl

use Crypt::PasswdMD5;
my $password = @ARGV[0];

$cryptedpassword = unix_md5_crypt($password, $salt);
print "$cryptedpassword\n";

The above takes the password as the argument.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Hardware and OS Related Technologies / Linux, Unix, and *nix like Operating Systems
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved