htpasswd generator and checker
Runs in your browserCreate htpasswd entries with bcrypt, APR1 or SHA1 and get ready-made config for nginx, Apache, Traefik (with $$), Caddy and ingress-nginx. Check a password against a line.
Paste one or more lines from an .htpasswd file and a password. Each line is checked in your browser.
What htpasswd can store
| Prefix | Format | Rating | Who reads it |
|---|---|---|---|
$2y$ | bcrypt (htpasswd -B) | Use this | Apache 2.4, nginx (via the system’s crypt), Traefik, Caddy, ingress-nginx |
$apr1$ | APR1-MD5, the htpasswd default | Weak | Apache, nginx, Traefik |
{SHA} | SHA-1 without salt (htpasswd -s) | Avoid | Apache, nginx |
| 13 characters | DES crypt (htpasswd -d) | Avoid | only the first 8 characters of the password count |
Make the same file without a browser
htpasswd -B -c /etc/nginx/.htpasswd admin # asks for the password htpasswd -nbB admin 'password' # print the line, no file
docker run --rm httpd:2.4 htpasswd -nbB admin 'password' printf 'admin:%s\n' "$(openssl passwd -apr1 'password')" >> .htpasswd # APR1 only
# docker-compose labels: every $ must be doubled echo $(htpasswd -nbB admin 'password') | sed -e 's/\$/\$\$/g'
caddy hash-password --plaintext 'password'
Why the login prompt keeps coming back
Compose replaces $2y with an empty variable. Double every $ in labels; the Traefik output above does that.
nginx runs as www-data or nginx and must be able to read the file. chmod 640 and the right group.
nginx checks bcrypt with the system’s crypt(). Older distributions without libxcrypt don’t know $2y$ there; APR1 always works because nginx implements it itself.
ingress-nginx expects the file under the key auth, and the annotation must name the secret in the same namespace.
Questions about the htpasswd generator
Which algorithm should I use for htpasswd?
bcrypt (htpasswd -B). It is deliberately slow, salted and supported by Apache 2.4, nginx, Traefik and Caddy. APR1-MD5 is the old default and much faster to crack.
How do I check a password against an .htpasswd file?
htpasswd -vb .htpasswd user password on the command line, or paste the line into the Check tab above.
Are the passwords sent anywhere?
No. The hashes are computed in your browser with the same algorithms htpasswd uses, and the page can’t send data anywhere.
What bcrypt cost should I use?
10 to 12. Each step doubles the time; the server pays it on every request with Basic auth, so very high costs slow down every page load.