Quick htpasswd Creation on Linux. Only The Useful.

Quick htpasswd Protection Setup On Linux.


cody@taylor:~$  <--This is the prompt. You do not need to type this

In the console get into the directory that you wish to protect.

cody@taylor:~$ cd /var/www/protected

Get the full path to the directory if you don’t already know it.


cody@taylor:~$ pwd

Create the htaccess file and add the following lines.


cody@taylor:~$ vim .htaccess
AuthUserFile /var/www/protected/.htpasswd
AuthName "This Site"
AuthType Basic
Require valid-user

Next use the htpasswd linux command which should be in the most common distros.


cody@taylor:~$ htpasswd -c .htpasswd someguy
New password: 
Re-type new password:

Almost done. Now you need to set the permissions on the files we just created.


cody@taylor:~$ chmod 755 .htaccess .htpasswd

All good.

Share

Leave a Reply