Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brasey/5c4ddc807355cbaa3864 to your computer and use it in GitHub Desktop.
Save brasey/5c4ddc807355cbaa3864 to your computer and use it in GitHub Desktop.
Generate a Linux password hash suitable for shadow file

Generate a Linux password hash suitable for shadow file

Need

Someone gives me a password to configure for a local Linux user account. We're managing local user accounts with Puppet, which needs a hash just like the one that's in /etc/shadow. Setting the password through manual means is not an option.

Solution

This Python foo:

python -c 'import crypt; print crypt.crypt("actual password here", "$6$random_salt")'

so to make a hash of the password 'password' using salt = cMLi2vqIIJtq1Shm

python -c 'import crypt; print crypt.crypt("password", "$6$cMLi2vqIIJtq1Shm")'
$6$cMLi2vqIIJtq1Shm$NPPssNooZjJdjT6SqKFS6IBiodoczgmACHLennml8kq1KHWwMQ5M4WNzgVdQR9JB5aGyuMFVNaLPxo3JRwLqm/

You can take that string and put it in /etc/shadow and be in business.

Credits

Thanks to this post for the answer.

@kmkmjhyiiiu
Copy link

kmkmjhyiiiu commented Jul 3, 2020

Here i created a tool for generating shadow password easily.

Btw results might be different. Because i openssl with md5 salt. sooo this will make impact?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment