Yale University

Y-Menu.
 

Help Desk
203-432-9000

ITS Office
Yale University
175 Whitney Avenue
P.O. Box 208276
New Haven, CT
06520-8276
USA

Yale logo.

Web support & webmaster services: Web technology & search engine support

Password protecting Web sites on the Medical Campus Web server

To password protect the files in a Web directory you need to create two files in the directory you want to protect, ".htaccess" and ".htpasswd". You may only password protect an entire directory.

If you would like information on how to IP protect an entire directory please see the instructions on IP Protecting Your Web Documents.

Instructions

While in the directory you wish to protect do the following:

1. Create the .htaccess file

Create a file named .htaccess (the filename must be exact, use all lower case letters and be sure to include the leading period in the file name). You can create the .htaccess file with any text editor or on your local computer.

You will need to transfer the file to the directory you wish to protect on the server if you are working locally on your machine. On the info.med.yale.edu Web server you can use the "pico" editor, typing the command:    pico .htaccess

In all of the following examples change the all bold items to be correct for your directory information.

The contents of the .htaccess file must have the following format:

AuthUserFile /usr/web/htdocs/PATH_TO_PROTECTED_DIR/.htpasswd AuthGroupFile /dev/null AuthName "this file" AuthType Basic

<Limit GET POST> require valid-user </Limit>

2. Create the .htpasswd file

To create the ".htpasswd" file, log onto info.med.yale.edu using telnet and:

1. Change into the protect directory by typing:   
cd PROTECTED_DIRECTORY

2. Create the ".htpasswd" file for the first user by typing the following: (make sure to use the '-c' flag only the first time to create the file called".htpasswd" in this directory)

htpasswd -c .htpasswd user_id
(enter a password for new user and verify)

3. Enter a password for other users:

htpasswd .htpasswd user_id_1
(enter a password for new user 1)
htpasswd .htpasswd user_id_2
(enter a password for new user 2)

After you have successfully created the first user(s) and password(s) and you later want to add another: Repeat steps 1 and 3 above to create the new users password in the ".htpasswd" file

If you want to delete a user ID, delete the user's entire line in the ".htpasswd" file with any text editor.WS.

 
Jump to top.