On www.gmu.edu it is possible to ensure that web visitors must enter a login and password to access a certain directory.
While this technique will prevent most web visitors from accessing the contents of your protected directory, this isn’t a particularly secure method. The password is sent in the clear, and in most cases, anyone who has server access to the Mason Cluster could download your files through SFTP.
Do not rely on this technique to protect confidential information.
Connect to the Mason Cluster.
Enter the following command:
your_directory_path appropriately. (e.g., if your site is located at www.gmu.edu/departments/english,
your_directory_path would be
If you have a directory already created for the page(s) that you want to protect, change into that directory:
Otherwise, create the directory first:
To create the file that will hold the usernames and passwords enter the following command:
/usr/bin/htpasswd -c .htpasswd username
Note: Replace username with whatever username you’d like and keep in mind that it’s case sensitive.
To add more users run the command again, without the
/usr/bin/htpasswd .htpasswd username
To create the file that ensures the directory is protected enter the following command:
You are now in a text editor. Copy and paste the following code:
AuthName "Password Protected Directory"
require user username
Replace with your own values where appropriate. To add multiple users add more lines to the
require user username1
require user username2
Save the file
(Ctrl+O) and exit
Set permissions on your
.htpasswd files to 644.
Test by trying to access the directory through a web browser. If it is properly set up, you should get a login prompt, and be able to log in with one of the usernames you created.