htpasswd Generator
Create the password file for HTTP Basic auth, check a password against a file you already have, and copy the nginx, Apache, Caddy or Traefik config that uses it.
Free · No signupHashed in your browser
htpasswd generator
Keeps its other users and replaces anyone you add here, as htpasswd does without -c.
# Give each user a password, or generate one. # The file appears here, one username:hash per line.
Basic auth sends the password with every request, encoded but not encrypted. Serve the site over HTTPS. Changes to the file apply on the next request, with no reload.
Prefer your terminal?
sudo htpasswd -c -B -C 10 /etc/nginx/.htpasswd adminIt asks for the password, so it stays out of your shell history. -c creates the file and replaces one that is already there.
Hashed in this tab. Passwords and files never leave this page.
Basic auth is a quick gate, not a strategy
Manage real access across your servers.
CtrlOps gives every teammate their own SSH key on the login they need on each server, so access is granted and removed per person, with credentials encrypted on your own machine.
Keep it handy
htpasswd hashes,
side by side.
The prefix tells a server how a line was hashed. The htpasswd column is the flag that makes it, and the last two say where each one can be checked.
| Algorithm | Prefix | htpasswd | Security | nginx | Apache |
|---|---|---|---|---|---|
| bcrypt | $2y$ | -B | Strong. Use this. | Through the system crypt(): current distros | 2.4 and later, every platform |
| SHA-512 crypt | $6$ | -5 | Fair. Salted, 5,000 rounds | Linux | Linux |
| apr1 | $apr1$ | -m | Weak. Iterated MD5 | Yes | Yes |
| SHA-1 | {SHA} | -s | Very weak. Unsalted | 1.3.13 and later | Yes |
| crypt | none | -d | Broken. 8-character limit | Linux | Linux |
How Basic auth works
One line per user.
Checked on every request.
What is an .htpasswd file?
An .htpasswd file stores the logins for HTTP Basic authentication, one username:hash line per user. nginx and Apache read it to put a password in front of a path, which makes it the quickest way to close off a staging site, a dashboard or an internal tool. The passwords are never stored, only their hashes, and this tool makes those hashes in your browser.
Which hash should you use?
Use bcrypt ($2y$). It is salted and slow by design. Apache has read it since 2.4. nginx hands it to the operating system's crypt(), which reads bcrypt on current Debian, Ubuntu, RHEL 8 and later, Alpine and the official nginx images. On CentOS 7, Amazon Linux 2 or Ubuntu 18.04, a bcrypt line gets a 500 error, so use SHA-512 crypt ($6$) there. apr1 and SHA-1 still work everywhere, but a leaked file gives their passwords up quickly.
Why the bcrypt cost matters more here
A browser sends the password with every request, and neither nginx nor Apache remembers that it already checked it. So a page with thirty images and scripts runs the hash thirty times. Each step up in cost doubles the work. Cost 10 is a sound default; htpasswd itself uses 5 for this reason. The tool times the hash on your device so you can judge it.
Where the file belongs
Keep it outside the web root. Apache refuses to serve files starting with .ht, but nginx has no such rule, so an .htpasswd in the document root can be downloaded. The server reads the file on each request as its worker user, so make it root:www-data with mode 640. Edits apply on the next request, with no reload.
Basic auth needs HTTPS
The browser sends username:password base64-encoded, which anyone on the path can decode. Serve the site over HTTPS. Protecting the whole site also blocks Let's Encrypt renewals, so the generated nginx and Apache config lets /.well-known/acme-challenge/ through. Basic auth guards a URL, not the server behind it.
htpasswd FAQ
Basic auth,
explained.
Add one or more username/password pairs here, pick a hash (bcrypt recommended), and copy or download the generated file - each line is username:hash. On a server you can also run htpasswd -cB /etc/nginx/.htpasswd username to create it, or htpasswd -B to add more users.
bcrypt ($2y$) is the strongest and recommended choice - it is salted and deliberately slow. apr1 is Apache's iterated-MD5 scheme; it is portable but weak. Plain SHA-1 ({SHA}) is unsalted and weakest. Use bcrypt unless an old server forces otherwise.
Add auth_basic "Restricted"; and auth_basic_user_file /etc/nginx/.htpasswd; inside the location or server block, then run nginx -t and reload. The .htpasswd file holds the hashed credentials this tool generates.
The stored hashes are fine (use bcrypt), but HTTP Basic auth transmits credentials base64-encoded on every request, which is not encryption. You must serve it over HTTPS so TLS protects the credentials in transit; on plain HTTP they are effectively sent in the clear.
Yes. This tool does it in the browser, and you can also use openssl: openssl passwd -apr1 generates an apr1 hash, and openssl passwd -6 generates a SHA-512 crypt hash (supported by some servers). For bcrypt, htpasswd -nbB user password is the simplest CLI route.
Each user is just another username:hash line in the same file. Add as many rows as you need here and the tool outputs the complete file. On a server, use htpasswd (without -c, which would overwrite) to append additional users.
Keep working
Related tools for your next task.