Linux password hash ($6$) generator
Runs in your browserCreate 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
What the prefix in /etc/shadow means
| Prefix | Method | Where |
|---|---|---|
$6$ | SHA-512-crypt | Linux /etc/shadow (default on many distributions), openssl passwd -6, mkpasswd -m sha-512 |
$5$ | SHA-256-crypt | Linux /etc/shadow, openssl passwd -5 |
$y$ | yescrypt | Linux /etc/shadow on Debian 11+, Ubuntu 22.04+, Fedora 35+ |
$1$ | MD5-crypt | old Linux /etc/shadow, openssl passwd -1 |
(none) | DES crypt | very 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.
Create the same hash on the command line
openssl passwd -6 'password' # random salt openssl passwd -6 -salt 'saltsalt' 'password' # fixed salt, same result as above
mkpasswd -m sha-512 'password' # package whois mkpasswd -m sha-512 -R 656000 'password'
echo 'deploy:$6$…' | sudo chpasswd -e sudo usermod -p '$6$…' deploy
#cloud-config
users:
- name: deploy
lock_passwd: false
passwd: "$6$…"- ansible.builtin.user:
name: deploy
password: "{{ 'password' | password_hash('sha512') }}"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.