What is htpasswd?
Htpasswd is a file that creates protected areas on a website using Apache HTTP Server. The file includes a username and password separated by a colon, with encryption using the UNIX system crypt method and hashing through either MD5 or SHA1 algorithms. Use our free online htpasswd generator tool to generate htpasswd.
How to generate htpasswd through the htpasswd generator?
Generating htpasswd files is easy. The online htpasswd generator creates passwords that are encrypted using the MD5 algorithm and compatible with all platforms, including Windows, MacOSX, and Linux. If you need multiple authentication records, use an online bulk htpasswd generator tool. Ensure password security by using a password generator.
How to protect folders in Apache?
Protect specific folders in Apache by placing a .htaccess file in the directory. The rules and directives in the .htaccess file apply to the directory and all its sub-directories.
AuthUserFile /path/to/.htpasswd
AuthType Basic AuthName "My restricted Area" Require valid-user
What are the steps to secure folders in Apache?
To secure a particular folder, you will need to modify your website’s Apache configuration, such as:
location /api {
auth_basic "Administrator's Area";
auth_basic_user_file /path/to/.htpasswd;
}
You have the option to restrict access to the entire website using basic authentication while keeping certain sections of the website accessible to the public. To achieve this, you can use the auth_basic directive and specify the “off” parameter to disable inheritance from higher configuration levels.
server {
...
auth_basic "Administrator's Area";
auth_basic_user_file /path/to/.htpasswd;
location /public/ {
auth_basic off;
}
}
Can multiple entries be stored in a single htpasswd file?
Yes, multiple username and password entries can save in one htpasswd file. Simply add a new login entry on each new line.
Example of htpasswd generator:
Sample list:
User: Admin
Password: 123
Generated htpasswd:
Admin:$2y$12$Vg2AK1n11mrqeETzP26s9.FfKY2uO0PrV8CNWXTrAegq3pgiIAYmS
Here you can see our more free Online Security Tools.