Welcome to WebmasterWorld Guest from

Forum Moderators: bakedjake

Message Too Old, No Replies

batch add *nix users

how to encrypt passwords?



4:00 pm on Dec 9, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member


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


4:23 am on Dec 20, 2005 (gmt 0)

5+ Year Member

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

That help?


11:48 am on Dec 21, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member

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?


5:50 pm on Dec 29, 2005 (gmt 0)

10+ Year Member

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 [ripe.net...] 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...] )


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

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

The above takes the password as the argument.


Featured Threads

Hot Threads This Week

Hot Threads This Month