Brock Cameo

  COSC 2P89
.htaccess information

Fall
2017


.htaccess file (exactly as shown with noted variations and note the file name must include the .)

AuthName MySecurity (some chosen text with no spaces or special characters)
AuthType Basic
AuthUserFile /home/std/ab12cd/public_html/myfile (ab12cd should be your id & myfile should be your chosen password file name)
Require valid-user

  1. Creating this file with world/other read permission causes the web server to show a password dialog before displaying web pages within public_html.
  2. To ensure world read permission you could issue the command chmod o=r .htaccess
  3. The file titled myfile (your name might be different) is the file of usernames and passwords allowed to view web pages.
  4. This file must also have world/other read permission.
  5. Creating the file and adding users and password is described below.

htpasswd command

  1. In order to prepare the password file you will need to login to sandcastle (see lab 1) and position yourself to the public_html directory.
  2. To see the options for the htpasswd command simply type htpasswd and press return.
  3. To create a new password file type htpasswd -c myfilename firstusername.
  4. You will be prompted for the password twice and after having done so the file is created with one user entry.
  5. You can add other users with htpasswd myfilename someotherusername. Do not supply -c for other user entries as this is only needed the first time.
  6. You can view the contents of the file with the cat command, such as cat myfilename. This will display the users and the encrypted version of the passwords.
  7. You can change the password of an existing user with htpasswd myfilename useralreadyinthefile and will be prompted for the new password.
  8. Note that the password file name will be referenced in the AuthUserFile line of the .htaccess file as described above.
  9. The password file must also have world/other read permission.

Computer Science Department | COSC 2P89 Home