Basic Auth with htpasswd


If you would like to protect a subdirectory with a basic username and password

  • Connect to one of the ETS Linux machines.
  • Create a “.htaccess” file in the directory that contains the items you want to protect.
Authtype Basic
AuthName "Put whatever you want here"
AuthUserFile <path to your htpasswd file>
Require valid-user

The path to your file should be your full Unix home directory.

For faculty/staff it might look like this: /top/people/home/public_html/.htpasswd
For students: /top/students/people/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.