Engineering Network Services - CSU
Basic Auth with htpasswd
If you would like to protect a subdirectory with a basic username and password
- Connect to one of the ENS Linux machines.
- Create a ".htaccess" file in the directory that contains the items you want to protect.
AuthName "Put whatever you want here"
AuthUserFile <path to your htpasswd file>
The path to your file should be your full Unix home directory.
For faculty/staff it might look like this:
/top/<academic or admin>/<Dept abbrev>/people/<your login name>/home/public_html/.htpasswd
/top/students/<GRAD or UNGRAD>/<Dept abbrev>/people/<your login name>/home/public_html/.htpasswd
- Creating a password file is done by using the "htpasswd" command like this:
htpasswd -c /httpdocs/foo/.htpasswd fred
The "-c" option creates the file for the first time. Don't use it if you are adding another user to an existing file. "fred" is the username you are adding. It will then ask you for a password and then to confirm it. After that you should be able to access the URL and be asked for the username and password.
This document last modified Wednesday June 06, 2018