Skip Navigation
IT Connect
Connecting You to Information Technology at the UW

 

Basic Group Password Protection

IT Connect > Web > Publishing > Basic Group Password Protection

This article describes how to password protect your Web site based on your own group of users. Like Basic Password Protection, you create a .htaccess file to turn on password protection and use the htpasswd command to define the names and passwords used to log in to your Web site. Here you also create a separate .htgroup file to define your group's name and its members.

To control access to your Web site using basic group password protection

  1. StepsActions
  2. Log into your web development server using a terminal emulator. If you're not sure how to do this, click here for instructions.

  3. At the prompt, enter the following command to change directories to your Web directory:

    cd public_html

    If you want to password protect a subdirectory rather than your whole Web site, change directories to the subdirectory you want to protect. For example:

    cd private
  4. At the prompt, enter the following command to create a .htaccess file in the current working directory:

    pico .htaccess
  5. Add the following text to this file:

    AuthType Basic
    AuthUserFile .htpasswd
    AuthGroupFile .htgroup
    AuthName "Town of Bedrock"
    require group flintstones
  6. Replace "Town of Bedrock" with your choice of text. This text is displayed when users are prompted for a name and password. Use something short that describes your password protected Web site.

  7. Now replace "flintstones" with the name of your group (all lowercase). For example:

    require group peanuts
  8. Save and close the file using Pico. (Click for instructions on how to use pico).

  9. At the prompt, enter the following command to create a .htgroup file in the current working directory:

    pico .htgroup
  10. Enter the name of your group, followed by a colon. Then list the members of the group, separating the names with spaces. For example:

    peanuts: charlie lucy linus sally snoopy pigpen
  11. Save and close the file using Pico. (Click for instructions on how to use pico).

  12. Now you need to enter names and passwords into your .htpasswd file. At the prompt, enter the following command to create a password file:

    htpasswd -c .htpasswd charlie

    Change "charlie" as needed. This command prompts you to enter and confirm "charlie's" password.

    Tip: If you get a "command not found" error message, you probably skipped step 2.

    To create passwords for additional names and add them to the password file you just created, enter the following command:

    htpasswd .htpasswd lucy

    Substitute "lucy" as needed and repeat for each name you defined earlier (step 10). For example:

    htpasswd .htpasswd linus
  13. You're done! Confirm that password protection is working by opening your Web site with a Web browser.