Skip to content

Instantly share code, notes, and snippets.

@geekpete
Last active May 27, 2018 18:28
Show Gist options
  • Save geekpete/7329085 to your computer and use it in GitHub Desktop.
Save geekpete/7329085 to your computer and use it in GitHub Desktop.
One line python command to generate a SHA512 password hash for use in linux shadow file including a randomised salt value. Change MySecretPassword to the password of your choice. Useful for generating password hashes to be used in puppet user manifests. This script is mildly idiotic. Bash will prevent any non-escaped characters being fed into py…
python -c "import random,string,crypt,getpass,pwd; randomsalt = ''.join(random.sample(string.ascii_letters,8)); print crypt.crypt('MySecretPassword', '\$6\$%s))\$' % randomsalt)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment