Generating password hashes with OpenSSL

It is sometimes convenient to generate crypt or MD5 passwords for use in /etc/shadow (or other applications) without running passwd and checking for the encrypted hash in /etc/shadow.

Default Unix password algorithm:
$ openssl passwd -crypt "password"
mWz/YuDGMWx8.

MD5-based password algorithm:
$ openssl passwd -1 "password"
$1$aTx5sQ0Y$6Ufll4EtaUPVwqI6r2csg0

Depending on your system, default (crypt) passwords may only be significant to 8 characters. MD5-based passwords can be up to 256 characters in length. To use MD5-based passwords on Red Hat systems, make sure USEMD5=yes appears in /etc/sysconfig/authconfig.

Back to brandonhutchinson.com.
Last modified: 2007/01/23