Linux password hash (/etc/shadow)

Make the password hash for /etc/shadow and /etc/passwd: SHA-512 ($6$), SHA-256 ($5$), bcrypt ($2y$) or MD5 ($1$) crypt, with the full shadow line.

loading Linux password hash (/etc/shadow)
About this tool

What is a Linux password hash?

Linux does not store passwords. It stores a hash of each one in /etc/shadow, in a format called crypt(3). When you log in, the system hashes what you typed with the same salt and compares the result. A line in /etc/shadow looks like alice:$6$salt$hash:20779:0:99999:7:::: the user name, the hash, and some password ageing fields. The characters between the first dollar signs name the algorithm: $6$ is SHA-512, $5$ is SHA-256, $2y$ is bcrypt and $1$ is the old MD5 crypt.

You need to make a hash by hand when you create users in a script, in a Dockerfile, in a Kickstart or cloud-init file, in Ansible's user module, or when you reset a password for a machine you can only reach by editing files. This page does that in your browser: pick the hash type, type the password, and get the hash, the complete line for /etc/shadow and the line for /etc/passwd. It also checks a password against an existing hash, and detects the type from the prefix.

The algorithms are the real ones. SHA-512 and SHA-256 crypt follow Ulrich Drepper's specification, with 5000 rounds by default and a configurable count, and MD5 crypt follows the original by Poul-Henning Kamp. bcrypt uses a cost, which is a power of two of rounds. The tests compare the output with the published test vectors and with openssl passwd. The page also reads Apache's $apr1$ and {SHA} formats, used by .htpasswd files; for those see the htpasswd generator.

Every new hash has a new random salt, so the same password gives a different hash each time, and all of them are valid. The tool does not make yescrypt ($y$), the newest default of Debian and Ubuntu. SHA-512 is accepted by every Linux and is a reasonable choice. Everything runs in your browser, and the password is not sent anywhere. Still, a hash is a target: do not publish it, because anyone with the hash can try passwords offline.

How to make and check a hash

  1. Type the Password:. Non-ASCII characters are hashed as UTF-8.
  2. Choose the Hash type:. SHA-512 is the Linux default. bcrypt asks for a Cost (2^n):, the SHA types ask for Rounds:, and MD5 shows a warning because it is old and fast to attack.
  3. Optionally type a Salt (optional):. Empty means a random one. The salt may have letters, digits, "." and "/".
  4. Type the User name: to build the lines for /etc/shadow and /etc/passwd.
  5. Click Generate new hash. Copy the Hash:, the Line for /etc/shadow: or the Line for /etc/passwd:.
  6. To apply it, run usermod -p 'HASH' user or use chpasswd -e, with the hash in single quotes because it has dollar signs.
  7. To check, open Check a password against a hash, type the Password: and the Hash:, and read whether it matches. Use the hash above copies the one you just made.

Examples

SHA-512 with a fixed salt

The password Hello world! with the salt saltstring and the default 5000 rounds gives the reference value from the specification:

$6$saltstring$svn8UoSVapNtMuq1ukKS4tPQd8iKwSMHWjl/O817G3uBnIFNjnQJuesI68u4OTLiBFdcbYEdFCoEOfaS35inz1

With SHA-256 the result is $5$saltstring$5B8vYYiY.CVt1RlTTf8KbXBH3hsxY/GNooZaBBGWEc5. With a rounds value other than 5000 the hash states it, as in $5$rounds=10000$saltstringsaltst$3xv.VbSHBb41AL9AvLeujZkZRBAwqFMz2.opqey6IcA, where the salt was cut to 16 characters.

MD5 crypt, and Apache's variant

The password secret with the salt abcdefgh:

$1$abcdefgh$cHJi5PXp/ki/ktXzqlk6I1
$apr1$abcdefgh$h9FWgUz3n9YxylKLlR5SQ/

The first is what openssl passwd -1 writes and the second what openssl passwd -apr1 and htpasswd -m write. Use them only for systems that cannot read anything newer.

The lines for the files

For a user alice the tool makes a /etc/passwd line like this, and a /etc/shadow line with the hash, the date as days since 1970 and the usual ageing fields (0, 99999 and 7):

alice:x:1000:1000::/home/alice:/bin/bash

For a shadow line, alice:$6$x$y:20779:0:99999:7::: is what you get for the hash $6$x$y on 22 November 2026.

A bcrypt hash and the 72-byte limit

A bcrypt hash looks like $2y$10$ followed by 53 characters. bcrypt reads only the first 72 bytes of the password, so the page warns you if yours is longer. For a general bcrypt tool see the bcrypt page.

Common mistakes

  • "This is not a hash of a known type. Expected $6$, $5$, $1$, $apr1$, $2y$ or {SHA}." The text to check is not in one of these formats. A yescrypt hash ($y$) cannot be checked here.
  • "This hash is damaged or incomplete." The prefix is right but a part is missing. Copy the hash again, and watch for a shell that expanded the dollar signs.
  • "The salt can have at most {max} characters." The limit is 16 for SHA and 8 for MD5.
  • "The character "x" cannot be in a salt. Use letters, digits, "." and "/"." Remove other symbols.
  • "Rounds must be a whole number from 1000 to 999999999." The SHA types need at least 1000 rounds.
  • "The bcrypt cost must be from 4 to 15." Pick a value inside the range.
  • "A user name has letters, digits, "_" and "-", and starts with a letter or "_"." Fix the name.
  • Unquoted hashes in the shell. Without single quotes, $6 and the rest are read as variables, and the hash is broken. Always quote it.

Frequently asked questions

Which type should I choose?

SHA-512 for general Linux use, since every distribution reads it. Raise the rounds above 5000 if the machine can bear the cost at login. Use bcrypt only where the system supports $2y$.

Can a hash be reversed?

No, but a weak password can be guessed. An attacker who has the hash can try millions of passwords per second on modern hardware, so the strength of the password matters more than the algorithm. Test yours with the password strength analyser.

Why is the hash different each time?

Because the salt is random. This is a feature: it stops two users with the same password from having the same hash, and it defeats precomputed tables.

Does it match mkpasswd and openssl passwd?

Yes, when you use the same type, salt and rounds. Compare with openssl passwd -6 -salt saltstring 'Hello world!'.

Make the same hashes on the command line

Bash

# SHA-512 with a given salt
openssl passwd -6 -salt saltstring 'Hello world!'

# with random salt, from the whois package
mkpasswd -m sha-512 'Hello world!'

# set it on a user
sudo usermod -p '$6$saltstring$...' alice
Report a problem