Edit History Actions Discussion

Diff for "Howto/Webpage/PasswordProtection"

Differences between revisions 1 and 2
Revision 1 as of 2009-01-14 20:10:10
Size: 1046
Editor: independence
Comment: password protected dir in public_html
Revision 2 as of 2009-01-14 20:29:07
Size: 1130
Editor: independence
Comment: keywords
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
#pragma keywords htaccess, htpasswd, apache, http auth, password, password protect

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