htpasswd Generator
Generate htpasswd entries for Apache, Nginx, and Traefik basic auth.
Client-side only — nothing leaves your browser
Quick Start (Terminal)
Prefer the command line? Create an htpasswd file with bcrypt (recommended) and a single user:
htpasswd -cB .htpasswd aliceReplace -B with -m for apr1 MD5, -s for SHA-1, or -p for plain text. Drop -c when adding users to an existing file.
What is htpasswd?
htpasswd is the standard utility for creating and updating the flat-file user database that powers HTTP Basic Authentication. Each line is a single user record in the form username:hash. The file is consumed by Apache (AuthUserFile), Nginx (auth_basic_user_file), Traefik (basicAuth.users), the Docker Registry, and many other reverse proxies and embedded servers.
htpasswd File Format
An .htpasswd file is plain text. Each line is one user, with the username and hash separated by a colon:
bob:$2y$10$KIXxPfnK7zXfWNXJ6lF.0OpJ8hFqQp0L4kRxK3aXjY1OYy7xQzT9C
carol:{SHA}W6ph5Mm5Pz8GgiULbPgzG37mj9g=
The prefix on the hash identifies the algorithm: $apr1$ for Apache MD5, $2y$ for bcrypt, $1$ for crypt(3) MD5, {SHA} for base64-encoded SHA-1, and no prefix for plain text. Usernames cannot contain a colon or whitespace.
htpasswd Hash Algorithms Compared
| Algorithm | Flag | Prefix | Security |
|---|---|---|---|
| bcrypt | -B | $2y$ | Strong (recommended) |
| apr1 (MD5) | -m | $apr1$ | Moderate, salted |
| crypt MD5 | (legacy) | $1$ | Moderate, salted |
| SHA-1 | -s | {SHA} | Weak (no salt) |
| Plain text | -p | (none) | None — avoid |
Using htpasswd with Your Server
Apache (.htaccess)
AuthName "Restricted Area"
AuthUserFile /etc/apache2/.htpasswd
Require valid-user
Nginx
auth_basic "Restricted Area";
auth_basic_user_file /etc/nginx/.htpasswd;
}
Nginx supports apr1, plain (with a special {PLAIN} prefix), SHA-1, and crypt(3). It does not support bcrypt directly — use apr1 if you need a browser-generated hash for Nginx.
Traefik (docker labels)
In Docker Compose labels, escape every $ as $$ — otherwise Compose tries to expand them as variables.
Docker Registry
The Docker Registry only accepts bcrypt — use -B.
Frequently Asked Questions
What is the htpasswd file format?
Which htpasswd algorithm should I use — bcrypt, apr1, or MD5?
Does Nginx support bcrypt in htpasswd files?
How do I add another user to an existing htpasswd file?
Can htpasswd hashes be decoded back to the original password?
Related Tools
Cron Generator
Generate, validate, and translate cron expressions. Visual cron builder with human-readable descriptions.
Cron to systemd Timer
Convert cron expressions to systemd .service and .timer files with OnCalendar syntax.
chmod Calculator
Visual chmod calculator. Toggle owner/group/other permissions, see octal (755) and symbolic (rwxr-xr-x) live.
Unit File Generator
Generate systemd .service, .timer, and .socket unit files visually. Set ExecStart, User, Restart, env vars, and Install target.
Unit File Validator
Validate systemd unit files. Paste a .service, .timer, .socket, or .mount file and catch missing directives, bad syntax, and errors.
Need to manage SSH connections?
SSH Workbench lets you connect, browse files, and manage servers visually.
Try SSH Workbench Free