Password Protect a directory
Creating a password protected site requires shell access to the server, and a small degree of familiarity with command-line text editing. Please don't hesitate to ask for help if any of this is unfamiliar to you, but also feel free to try this out on your own (there's very little you can hurt).
Telnet has been turned off due to security issues, so you'll have to use ssh to gain shell access to the server - get an ssh client for your computer.
Once connected you'll create three files - one in the directory
you want to password protect, and two in a sub-directory of your
home directory.
In each ~/Sites/directory you wish to protect create a text file called ".htaccess" with the following contents:
AuthName "Secure Site"
AuthUserFile /Users/username/userdb/.htpasswd
AuthGroupFile /Users/username/userdb/.htgroup
AuthType Basic
<Limit GET>
require group my-users
</Limit>
Remember to replace /home/username with the path
to your home directory, ie. if your username is bob then it'd be
/home/bob.
Create the userdb directory and the .htpasswd and .htgroup files with these commands:
[user@work user]# mkdir ~/userdb
[user@work user]# touch ~/userdb/.htpasswd
[user@work user]# touch ~/userdb/.htgroup
then make sure you're in your home directory (not your Sites directory!) and type:
[user@work user]# htpasswd userdb/.htpasswd [guest-user]
[guest-user] should be replaced with the login name
of the person you want to give access to. It will prompt you for
a password twice. This command must be completed for each guest-user.
(Advanced users: htpasswd -mb /Users/username/userdb/.htpasswd
frank franksPassWord would create a guest-user named
"frank" with a password of "franksPassWord" in all at once, assuming
you replace "username" with your login name.)
Finally, edit the userdb/.htgroup file and add the following:
my-users: guest-user1 guest-user2
Guest-user login names are separated with a space.
Note: If you want to have three sites all passworded under ~/Sites/site1 ./site2 and ./site3 with similar usernames but different passwords, you can make a .htaccess file in each directory pointing to something like /Users/username/userdb/.htpasswd1 ./htpasswd2 and ./htpasswd3 respectively.


















