Revision 1 as of 2009-01-14 20:10:10

Clear message
Edit History Actions Discussion

Howto/Webpage/PasswordProtection

Howto: Password Protection

This howto will briefly explain how to set up a directory on your webpage that requires username/password authentication for access.

First, create a new directory in your public_html where you will put the files which you want to protect:

cd ~/public_html
mkdir secret

Create a file named .htaccess in the new directory with the following content (edit with: nano -w secret/.htaccess for example):

AuthUserFile /var/www/users/myusername/secret/.htpasswd
AuthName "Secret directory"
AuthType Basic
Require valid-user

Remember to replace myusername in the pathname with your username.

The last step is to create the file that will store your usernames and passwords:

/usr/sbin/htpasswd -c secret/.htpasswd username

The last parameter here (username) is the name of the user for which you want to create a new password. If you want to add more users remove -c (create new) from the argument list and issue the command again.


CategoryHowto