Linux password hash ($6$) generator

Runs in your browser

Create SHA-512-crypt ($6$), SHA-256-crypt ($5$) and MD5-crypt hashes like mkpasswd and openssl passwd, for /etc/shadow, cloud-init and Ansible. Check a password.

Hash
/etc/shadow line
cloud-init
Ansible
Set it on a server
Formats

What the prefix in /etc/shadow means

PrefixMethodWhere
$6$SHA-512-cryptLinux /etc/shadow (default on many distributions), openssl passwd -6, mkpasswd -m sha-512
$5$SHA-256-cryptLinux /etc/shadow, openssl passwd -5
$y$yescryptLinux /etc/shadow on Debian 11+, Ubuntu 22.04+, Fedora 35+
$1$MD5-cryptold Linux /etc/shadow, openssl passwd -1
(none)DES cryptvery old Unix, htpasswd -d; only the first 8 characters count

An exclamation mark in front of the hash (!$6$…) means the account is locked for password login; * or ! alone means it never had a password. The hash format is $id$rounds=N$salt$hash, with rounds= only when it differs from 5,000.

In your terminal

Create the same hash on the command line

openssl
openssl passwd -6 'password'                  # random salt
openssl passwd -6 -salt 'saltsalt' 'password'    # fixed salt, same result as above
mkpasswd
mkpasswd -m sha-512 'password'               # package whois
mkpasswd -m sha-512 -R 656000 'password'
Set a password
echo 'deploy:$6$…' | sudo chpasswd -e
sudo usermod -p '$6$…' deploy
cloud-init
#cloud-config
users:
  - name: deploy
    lock_passwd: false
    passwd: "$6$…"
Ansible
- ansible.builtin.user:
    name: deploy
    password: "{{ 'password' | password_hash('sha512') }}"
FAQ

Questions about the linux password hash

How do I generate a password hash for /etc/shadow?

openssl passwd -6 or mkpasswd -m sha-512, or the tool above. Both produce SHA-512-crypt ($6$), which every Linux distribution understands.

What is $y$ in /etc/shadow?

yescrypt, the default on Debian 11+, Ubuntu 22.04+ and Fedora 35+. It can’t be created or checked here yet; SHA-512-crypt hashes work on those systems too.

Does the salt have to be random?

Yes, for real accounts. A fixed salt is only useful to compare a result with openssl or mkpasswd. Leave the field empty for a random 16-character salt.

Is it safe to type the password here?

The hash is calculated in your browser; nothing is sent. For root passwords of production machines you may still prefer openssl on the machine itself.

Searches the list of pages on this site. What you type stays in your browser.