Apache: Directories with password
Table of contents
Before getting into it I will remind that we configured it previosly with Apache:
Now that we're all on the same page, let's join together in a process of advanced Apache configuration while learning the basics.
This one will allow us to secure our folders with a password so that we can keep our most valuable files in control.
Our following task will be to choose which directory will be protected and create a .htaccess inside.
touch .htaccess
Introduction
Before getting into it I will remind that we configured it previosly with Apache:
Auth_basic Module
Once here I suppose that we're on the same page already, so why bothering with more explanations about modules, let's get into the key point.
How can I activate auth_basic module?
It is quite simple, just copy the following command scheme:
a2enmod auth_basic
Don't forget to restart apache after the activation.
This one will allow us to secure our folders with a password so that we can keep our most valuable files in control.
.htaccess && .htpasswd
Our following task will be to choose which directory will be protected and create a .htaccess inside.
touch .htaccess
AuthType Basic
AuthName "secure document"
AuthBasicProvider file
#Here is where we indicate the credentials
AuthUserFile /home/Enrique/public_html/.htpasswds
#Here we make sure that a login will be needed
Require valid-user
Before we get into the final result, it is time to create the credentials file.
touch .htpasswd
And the .htpasswd will look like this:
Once we created the .htpasswd it is simple to input username and password but insecure, my advice is to encrypt the password before getting into results or later on problems.
And the .htpasswd will look like this:
And finally, the result:
touch .htpasswd
And the .htpasswd will look like this:
Once we created the .htpasswd it is simple to input username and password but insecure, my advice is to encrypt the password before getting into results or later on problems.
SMALL TIP:
My advise is to use this page to generate it:
http://www.htaccesstools.com/htpasswd-generator/
And the .htpasswd will look like this:
And finally, the result:
What do you think? Will you try it?
Thank you for reading my amateur tutorial and I hope we'll keep improving together!
Comentarios
Publicar un comentario