Skip to content

Instantly share code, notes, and snippets.

@stefanschmidt
Last active April 7, 2019 22:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stefanschmidt/6e2e24397aa8ce42424be832a00cab2b to your computer and use it in GitHub Desktop.
Save stefanschmidt/6e2e24397aa8ce42424be832a00cab2b to your computer and use it in GitHub Desktop.
Generate salted SHA-512 hashes
# Using mkpasswd and slappasswd we will generate salted SHA-512 hashes
# password: secret
# method 1: using mkpasswd
# requires whois package on Ubuntu
mkpasswd --method=sha-512 --salt=foobar42
$6$foobar42$weYmU8biHjFLegPCuvGBSDaG0QMNucFv4Wq6.TGVK53/U0dp6bTrLYCLAdjecyX5mS1IA8vezYNjzTduU988B0
# method 2: using slappasswd
# requires slapd package on Ubuntu
# method 2a: with static salt
slappasswd -h {CRYPT} -s secret -c '$6$foobar42'
{CRYPT}$6$foobar42$weYmU8biHjFLegPCuvGBSDaG0QMNucFv4Wq6.TGVK53/U0dp6bTrLYCLAdjecyX5mS1IA8vezYNjzTduU988B0
# method 2b: with dynamic salt
# %.8s is replaced by 8 random characters
# see man page of slappasswd for details
slappasswd -h {CRYPT} -s secret -c '$6$%.8s'
{CRYPT}$6$X7g6B3FD$SH8Ii/AtZg8yrNvu3CwWwf0iXnUzCuaTSelzzL3DeJoY7JMkMD3yohDivtOSaWJQQOv6MHI0jRZ8c7rZGc5hq1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment