Protect Web Directories

How to Protect Your ONID Web Directories

  1. Create a text file named .htaccess with the following contents:

    AuthType Basic
    AuthName "Password Required"
    AuthUserFile /users/{uX}/{a}/{username}/.htpasswd
    require valid-user


    Replace {a} with the first letter of your username. This must be lowercase.
    Replace {username} with your ONID username.
    Replace {uX} with the user group that you are in.
    Login using SSH? and type "pwd". Using WinSCP you can find this information above the file list of your ONID directory. Lastly, you can guess, there should only be u1 and u2.

    You will need to save this txt doc as .htaccess, or so that the name is blank, and the file extension is of type .htaccess.
  2. Connect to ONID (shell.onid.oregonstate.edu) via SSH. Basic directions can be found by following the previous link. You will have to use the SSH Secure Shell client to connect and get a shell prompt.
  3. At the shell:~> prompt type htpasswd -c .htpasswd {username} and press enter to create the .htpasswd file in your home directory. Replace {username} with the username you would like to user for web authentication. Note: If you wish to password protect another directory, type cd {directory path} before you create the .htpasswd file. Replace {directory path} with the directory path e.g. public_html/spring2010/assignments
  4. Type the password you would like to use.
  5. Retype the password you would like to use.
  6. Move the .htaccess file from your computer to the directory you wish to password protect.