/etc/shadow hash generation in shell

Posted: 2009-08-17 17:25:51 by Alasdair Keyes

Direct Link | RSS feed

I've been playing about with system templating recently, configuring a base Linux system then allowing it to be customised for future roll-out without starting the machine up. I found the following little trick to generating password hashes as they appear within the /etc/shadow file. It uses the mkpasswd binary, there are many ways to generate the hash which use openssl and various password apps, but this was the most simple I came across.

I don't believe mkpasswd is in the CentOS yum repo, but is available in Ubuntu's apt repo (apt-get install mkpasswd).

MD5 hashed passwords as found as default on Redhat/CentOS systems

# mkpasswd -m md5 password saltsalt

SHA512 hashed passwords as found on Ubuntu

# mkpasswd -m sha-512 password saltsaltsaltsalt

If you found this useful, please feel free to donate via bitcoin to 1NT2ErDzLDBPB8CDLk6j1qUdT6FmxkMmNz

IT Consultancy Services

I'm now available for IT consultancy and software development services - Cloudee LTD.

Happy user of Digital Ocean (Affiliate link)


Validate HTML 5