htpasswd generator and checker

Runs in your browser

Create 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.

Hash formats

What htpasswd can store

PrefixFormatRatingWho reads it
$2y$bcrypt (htpasswd -B)Use thisApache 2.4, nginx (via the system’s crypt), Traefik, Caddy, ingress-nginx
$apr1$APR1-MD5, the htpasswd defaultWeakApache, nginx, Traefik
{SHA}SHA-1 without salt (htpasswd -s)AvoidApache, nginx
13 charactersDES crypt (htpasswd -d)Avoidonly the first 8 characters of the password count
In your terminal

Make the same file without a browser

htpasswd
htpasswd -B -c /etc/nginx/.htpasswd admin     # asks for the password
htpasswd -nbB admin 'password'                 # print the line, no file
Without apache2-utils
docker run --rm httpd:2.4 htpasswd -nbB admin 'password'
printf 'admin:%s\n' "$(openssl passwd -apr1 'password')" >> .htpasswd   # APR1 only
Traefik
# docker-compose labels: every $ must be doubled
echo $(htpasswd -nbB admin 'password') | sed -e 's/\$/\$\$/g'
Caddy
caddy hash-password --plaintext 'password'
Common mistakes

Why the login prompt keeps coming back

$ in docker-compose

Compose replaces $2y with an empty variable. Double every $ in labels; the Traefik output above does that.

Wrong file permissions

nginx runs as www-data or nginx and must be able to read the file. chmod 640 and the right group.

bcrypt and nginx

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 secret key

ingress-nginx expects the file under the key auth, and the annotation must name the secret in the same namespace.

FAQ

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.

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