Purdue University - Department of Biological Sciences

Markey Center for Structural Biology

arrow Home IT Support Documentation Password Protecting Web Directories

Password Protecting Web Directories

This short tutorial will show how to password protect your web directories. If you are having difficulty sending a large attachment (like a 100MB image file), this would allow you to upload the file and allow only people you want to access the file.

Step by step instructions are available for the following hosts:

ICS Web Directories

  1. Log on to a UNIX machine with htpasswd2 installed (like bilbo, for instance)
    Also log into web.ics.purdue.edu via ssh. On web.ics.purdue.edu type "pwd" and hit enter. Write down the results of that command.
  2. execute: "htpasswd2 -c .htpasswd <username>" and enter the desired password for <username> where >username< is the name you'd like to use for protecting the directory
  3. create a text file named .htaccess using pico or vi and place the following in the file:

    AuthUserFile <results from the "pwd" command from step 1>.htpasswd
    AuthName "Password Required"
    AuthType Basic

    require user <username>

    where <username> is the name you supplied above
  4. Save the file
  5. Log in via sftp to web.ics.purdue.edu
  6. put .htpasswd in home directory
  7. chmod 644 .htpasswd
  8. cd www
  9. mkdir <name of directory to be protected>
  10. cd <name of directory to be protected>
  11. place .htaccess file here
  12. ssh to web.ics.purdue.edu and run "webfix"

Anything you place in the directory with the .htaccess file is now protected. It may still be a good idea to encrypt any data you have in there as well.

If you want to change the password for that user, just run "htpasswd2 .htpasswd username" while in the same directory as the .htpasswd file. Change the password and upload it to your directory. You can also add and remove users this way as well.


bilbo.bio.purdue.edu Web Directories

  1. Log in to bilbo.bio.purdue.edu
  2. Make sure you are in your home directory and execute: "htpasswd2 -c .htpasswd <username>" and enter the desired password for <username> where >username< is the name you'd like to use for protecting the directory.
  3. chmod 644 .htpasswd
  4. cd to ~/WWW/ and create the directory you'd like to protect, if it doesn't exist already
  5. cd to ~/WWW/<directory you'd like to protect> create a text file named .htaccess using pico or vi and place the following in the file:

    AuthUserFile /home/<your username>/.htpasswd
    AuthName "Password Required"
    AuthType Basic

    require user <username>

    where <username> is the name you supplied above
  6. Save the file
  7. chmod 644 .htaccess

Anything you place in the directory with the .htaccess file is now protected. It may still be a good idea to encrypt any data you have in there as well.

If you want to change the password for that user, just run "htpasswd2 .htpasswd username" while in the same directory as the .htpasswd file. Change the password. You can also add and remove users this way as well.

If you encounter any errors, feel free to e-mail us.

Copyright © 2005, Purdue University, all rights reserved.
Purdue University, West Lafayette, IN 47907 USA, (765) 494-4600
Sitemap | Webmaster

Last modified: November 10 2005 10:57:08