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
-
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.
-
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
-
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
- Save the file
- Log in via sftp to web.ics.purdue.edu
- put .htpasswd in home directory
- chmod 644 .htpasswd
- cd www
- mkdir <name of directory to be protected>
- cd <name of directory to be protected>
- place .htaccess file here
- 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
-
Log in to bilbo.bio.purdue.edu
-
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.
- chmod 644 .htpasswd
- cd to ~/WWW/ and create the directory you'd like to protect, if it doesn't exist already
-
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
- Save the file
- 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.