This blog has moved! Redirecting...
You should be automatically redirected. If not, visit http://scrolls.mafgani.net/ and update your bookmarks.

Wednesday, January 25, 2006

HTTP Access Control

Finally figured out how to password protect individual directories on the server:

Authentication, Authorization and Access Control

It's a simple 2-step process:

1. Create a passwords file for the users using "htpasswd":

jsmith@server:~/public_html/db$ htpasswd -c ~/htpasswds jdoe
New password:
Re-type new password:
Adding password for user jdoe
jsmith@server:~/public_html/db$


2. Create a file ".htaccess" in the directory to be protected:

jsmith@server:~/public_html/db$ cat .htaccess
AuthType Basic
AuthName "db"
AuthUserFile /home/jsmith/htpasswds
Require user jdoe

2 Comments:

Blogger android said...

and where exactly does one place the htpasswd file?

2:02 AM  
Blogger DarkKnight said...

dude, I though you already had this thing going .. how else do you password protect your directories? Anyway, the passwords file can go anywhere and can be called anything -- just as long as you put down the correct location in the "AuthUserFile" line of .htaccess. The most sensible place to put it is somewhere in your homedir -- but not in public_html -- since people can then just download it off of the server.

2:18 AM  

Post a Comment

<< Home