Basic authentication

To protect some directory with basic authentication we have to edit the virtual host file and add some configurations like this:

<Directory /home/someuser/somesite/public_html>
    AuthType Basic
    AuthName "Authentication Required"
    AuthUserFile "/home/someuser/.htpasswd"
    Require valid-user
</Directory>

 Then we have to create the user credentials file (AuthUserFile) with htpasswd command, in this example we will be using the file "/home/someuser/.htpasswd"

Using bcrypt 

htpasswd -nbB USERNAME PASSWORD

Using MD5 

htpasswd -nbm USERNAME PASSWORD

 Using SHA1

htpasswd -nbs USERNAME PASSWORD

Using CRYPT

htpasswd -nbd USERNAME PASSWORD

 

https://wiki.apache.org/httpd/PasswordBasicAuth 

https://www.digitalocean.com/community/tutorials/how-to-set-up-password-authentication-with-apache-on-ubuntu-14-04

https://httpd.apache.org/docs/2.4/misc/password_encryptions.html

Back to top