Restricting Access to CAE Personal Homepages

Instruction on creating password protected personal homepages

This document will guide you to password-protect one file, multiple files, or even the entire site of your CAE personal homepages. So, when a user wants to access a file/multiple files/a page/multiple pages on your CAE personal homepages, the user will be prompted a username and a password. You will be the one who define the valid username and password.

Requirements:
Setting up CAE personal homepages
If you have set up you CAE personal homepages, you can skip this part. Otherwise, the instruction on setting up CAE personal homepages can be found here:
http://kb.wisc.edu/cae/page.php?id=6052

Procedures:
You can do it from both CAE Windows and CAE Linux workstations. Since the procedures need to set file permissions, using linux terminal is suggested.
  1. Locate public_html
    It is where your CAE personal homepages is located. The files created on the next two steps should be put in public_html directory.
    • From CAE Windows workstations:
      Run SecureCRT or any SSH client. SecureCRT can be found in Start->Programs->Internet->SecureCRT.
      Connect to best-tux.cae.wisc.edu and log in. Now, you are on a linux terminal
      Type 'cd public_html' without the quotes on the terminal and then press enter.
    • From CAE linux workstations:
      Right click on the desktop, run Open Terminal.
      Type 'cd public_html' without the quotes on the terminal and then press enter.

  2. Create .htpasswd file in public_html
    .htpasswd is a password file (There is a dot at the beginning of the filename). Password file stores all valid username and password. Here is some useful commands for creating a password file and adding a new username/password into a password file.

    • Create a new password file using htpasswd command
      htpasswd -c passwdfile username
    • Add a user to an existing password file
      htpasswd passwdfile username
    • Set the permission of the password file to be publicly readable (Important)
      chmod a+r passwdfile

    Example:
    terminal-htpasswd.jpg

  3. Create .htaccess file in public_html
    With the password file created, you are now ready to start restricting access to your web pages using .htaccess file.
    • Create a new text file in public_html directory called .htaccess using any text editor.
      ----------------------------------------------------------------------
      On a linux terminal, in this case using pico text editor:
      tux-95% pico .htaccess
      ----------------------------------------------------------------------
    • Put one the restrictions below depending on your need in .htaccess
      • Limit access to the entire CAE personal homepages
        Everyone needs a valid username and password to access your CAE personal homepages.
        AuthType basic
        AuthName "Password Protected Area"
        AuthUserFile /filespace/people/[first_char_cae_login]/[cae_login]/public_html/[passwdfile]
        require valid-user
        Header merge Cache-Control private
      • Limit access to a file or multiple files
        <Files [filenames]>
        AuthType basic
        AuthName "Restricted Files"
        AuthUserFile /filespace/people/[first_char_cae_login]/[cae_login]/public_html/[passwdfile]
        require valid-user
        Header merge Cache-Control private
        </files>
        Note: Make sure that there are no spaces between the file names in the first line.
        For example:
        <Files test1.html>
        <Files test1.html,test2.html,test3.jpg>

      • Limit access to particular user
        Put the username to have access on the require line.
        <Files [filenames]>
        AuthType basic
        AuthName "Restricted Files"
        AuthUserFile /filespace/people/[first_char_cae_login]/[cae_login]/public_html/[passwdfile]
        require user1 user2 user3
        Header merge Cache-Control private
        </files>
        Note: Be sure you have a password defined in your password file for the specified users.

      • Example: On a text editor, put a restriction and save the file. In pico, Ctrl+O then press enter to save, Ctrl+X to exit htaccess on pico
    • Set the permission for the .htaccess file to be publicly readable (Important)
      ----------------------------------------------------------------------
      On a linux terminal:
      tux-95% chmod a+r .htaccess
      ----------------------------------------------------------------------



Keywords:homepage homepages htaccess public_html restrict   Doc ID:13536
Owner:Noel K.Group:Computer-Aided Engineering
Created:2010-03-03 19:00 CDTUpdated:2016-06-17 09:29 CDT
Sites:Computer-Aided Engineering
Feedback:  1   0