{ htpasswd Generator }

// create secure password hashes for apache basic auth

Generate secure htpasswd hashes for Apache basic authentication. Supports MD5, SHA1, bcrypt and plain text formats. Free, browser-based, no sign-up required.

Allowed: letters, numbers, _ - . @
Compatible with all Apache 2.x versions.
🔐

Ready to generate

Fill in username & password, then click Generate

HOW TO USE

  1. 01
    Enter credentials

    Type the username and password you want to protect your Apache resource with.

  2. 02
    Choose hash format

    Select APR1-MD5 for broad compatibility, bcrypt for strongest security, or SHA1 for portability.

  3. 03
    Copy to server

    Paste the generated line into your .htpasswd file on the server and configure .htaccess.

FEATURES

APR1-MD5 SHA1 bcrypt Plain Text Server-side hashing Copy ready lines

USE CASES

  • 🔐 Protect staging environments
  • 🔐 Secure admin directories
  • 🔐 Add basic auth to dev servers
  • 🔐 Manage Apache virtual host access
  • 🔐 Quick password rotation

WHAT IS THIS?

The htpasswd Generator creates password hash entries compatible with Apache's Basic Authentication system. Apache reads a .htpasswd file to verify credentials before granting access to protected directories. This tool generates those hashed entries without needing shell access or the htpasswd command.

RELATED TOOLS

FREQUENTLY ASKED QUESTIONS

What is an htpasswd file?

An .htpasswd file is a flat-file database used by Apache HTTP Server to store usernames and hashed passwords for HTTP Basic Authentication. Each line contains one entry in the format username:hashedpassword.

Which hash format should I use?

Use APR1-MD5 for the best compatibility across Apache 2.x versions. Use bcrypt if you're on Apache 2.4+ and want stronger security — bcrypt is computationally expensive which makes brute-force attacks much harder. Avoid plain text in production.

Is my password sent to the server?

Yes — hashing is performed server-side in PHP, which is necessary for generating proper APR1-MD5 and bcrypt hashes. The password is transmitted over HTTPS and never stored or logged.

How do I use the generated hash?

SSH into your server and open (or create) the file at a path like /etc/apache2/.htpasswd. Paste the generated line. Then in your .htaccess, add: AuthType Basic, AuthName "Protected", AuthUserFile /path/.htpasswd, Require valid-user.

Can I add multiple users?

Yes. Simply generate a hash for each user and append each line to the same .htpasswd file. Each user gets their own line. To update a password, replace the existing line for that username.

Does SHA1 work with all web servers?

SHA1 ({SHA} prefix) is widely supported by Apache and also by Nginx when using auth_basic with the ngx_http_auth_basic_module. However SHA1 is considered weak by modern cryptographic standards — prefer APR1-MD5 or bcrypt where possible.

What is an htpasswd Generator?

An htpasswd generator is a tool that creates password hash entries in the format expected by Apache HTTP Server's Basic Authentication system. When you want to restrict access to a directory or web resource on an Apache server, the standard approach is to use an .htpasswd file — a simple text file where each line stores a username paired with a hashed version of their password.

Normally, you'd generate these entries using the htpasswd command-line utility that ships with Apache. However, that requires shell access to your server. This online generator replicates the same hashing algorithms in PHP, letting you create valid .htpasswd entries directly in your browser — no terminal, no Apache installation needed.

Understanding htpasswd Hash Formats

Apache supports several password hash formats, each with different security characteristics and compatibility considerations:

How Apache Basic Authentication Works

Apache's Basic Authentication mechanism is straightforward. When a browser requests a protected resource, Apache returns a 401 Unauthorized response with a WWW-Authenticate header. The browser then prompts the user for credentials and re-sends the request with a Base64-encoded Authorization header. Apache decodes this, extracts the username and password, finds the matching username in the .htpasswd file, hashes the submitted password with the stored salt, and compares against the stored hash.

Because the process happens at the Apache level — before any PHP, Node, or application code runs — it's an efficient and reliable way to protect resources like staging environments, admin panels, or internal documentation.

Setting Up Apache Basic Authentication Step by Step

Once you've generated your htpasswd entries, here's the complete setup process:

  1. Create the .htpasswd file: SSH into your server and create a file outside your web root for security — for example, /etc/apache2/.htpasswd or /home/user/.htpasswd. Paste the generated line(s) into this file.
  2. Configure .htaccess: In the directory you want to protect, create or edit an .htaccess file with the following directives:
    AuthType Basic
    AuthName "Restricted Area"
    AuthUserFile /absolute/path/to/.htpasswd
    Require valid-user
  3. Enable AllowOverride: In your Apache configuration (usually in httpd.conf or a virtual host file), ensure the directory has AllowOverride AuthConfig or AllowOverride All set.
  4. Reload Apache: Run sudo systemctl reload apache2 (or service httpd reload on older systems) to apply the changes.

Security Best Practices for htpasswd

While HTTP Basic Auth is convenient, there are important security considerations to keep in mind:

Nginx and Other Web Servers

While this tool is designed for Apache, the SHA1 and plain text formats are also compatible with Nginx's ngx_http_auth_basic_module. Nginx reads the same .htpasswd file format and supports SHA1 and crypt-based hashes. APR1-MD5 and bcrypt support in Nginx may require additional modules or compilation flags depending on your distribution.

For Nginx, the configuration equivalent looks like:

location /protected/ {
    auth_basic "Restricted Area";
    auth_basic_user_file /path/to/.htpasswd;
}

Why Use an Online htpasswd Generator?

The command-line htpasswd utility is only available on systems where Apache is installed. Developers working on Windows, designers setting up staging servers, or anyone without direct server access often need to generate these entries without a full Apache environment. This online tool fills that gap — it runs the same hashing algorithms server-side and delivers instantly usable output that you can paste directly into your server's .htpasswd file.

☕