Instructions For Password Protecting Your website.
You need 2 files in your www folder on the UNIX server with the names:
.htaccess
.users
Creating The .htaccess File
The content of the .htaccess file is below.
AuthName "Restricted"
AuthType Basic
AuthUserFile /home/acct2/YourUserName/www/.users
require valid-user
- One change you need to make is in AuthUserFile where you see /YourUserName/ You must replace it with your own user name.
- Another change you need to make is the path to your folder. You will not be password protecting your www folder but the folders for your assignments.
- So the line of code might look something like this:
AuthUserFile /home/acct2/Doe243/www/smallAssignments/.users
- Be very careful with spaces. Spaces should be exactly as you see them.
There are three ways to put this .htaccess file on the server in the www folder:
A.
1. Use NOTEPAD or any simple text editor.
2. Copy and paste the above content.
3. Replace YourUserName with your own user name.
4. Make sure the correct path to your .users file follows the www (www/----/.users). Be sure the folder/s is/are spelled exactly the same as the folder/s in your site.
4. Save this file as .htaccess
5. FTP this file to your www folder on the UNIX server. Instructions for FTP
6. It will show up as .htaccess.txt.
7. Important: Remove the .txt from the file name in the www folder by following directions 1- 4 below in B then remove the .txt from the file name. It is possible that your FTP software may allow you to change name of file on the server.
OR
B.
1. On the computer, find and click on VNC Viewer.
2. When asked for a server, type: springfield:1 Note - Don't forget the :
3. On the next screen, enter your user name and on the next screen, enter your password.
4. Open your www folder and open the folder to be protected.
5. At the top of the screen you will see an icon of a monitor. Click this and you will be in the terminal mode.
6. Type: cd www . This means change directory (folder) to www.
7. To be sure you are in the www directory, type: pwd and you should see that www is the last directory in the list. Navigate to the protected folder.
8. Type: emacs . This will put you into a text editor.
9. Press enter to exit the emacs tutorial
10. You cannot paste here, so type the file above exactly as it is with the exception of using your own user name.
11. Go to the Files pull down menu and select Save Buffer As
12. At the bottom of the emacs window, put curser at end of *scratch* and delete these characters.
Do not delete the / then type: .htaccess. The line at the bottom should look like this:
Write file: ~/www/.htaccess
13. Wait a minute or so and the file should show up in your www folder.
OR
C.
You can telnet to beast.tcnj.edu and follow the instructions 6 - 9 for B. above.
You save the file by pressing the control key and x then press w.
Creating the .users file
1. Click the monitor to get into terminal mode. Your interface may not have a monitor icon, in this case, you can find the terminal mode in the File pull down.
2. Type: cd www
3. Type: pwd to be sure you are in the www folder.
4. Type cd (the name of the folder you want to password protect.)
5. Type pwd to be sure your are in the folder you want to protect.
4. Type: htpasswd -c .users UserID
5. You will be asked to a add password for UserID and be prompted for a new password.
6. Enter a password.
7. You will be asked to re-type the new password. Re-type it.
8. Now the file is created and the folder (directory) is password protected. UNIX scrambles the password so that it cannot be read if anyone gets into this file.
I used telnet to get into the server from home and here is a copy of my interaction with the server.
beast[1]% cd www
beast[2]% cd PreviousCourses
beast[3]% cd Projects
beast[4]% pwd
/home/acct3/scott/www/PreviousCourses/Projects
beast[5]% htpasswd -c .users Serita
Adding password for Serita.
New password:
Re-type new password:
beast[6]%
Note:
- Make sure permissions are set properly for each of the files .htaccess and .users
- Make sure the .htaccess file has your user name and the correct path to the .users file.
- You can Google .htaccess and learn a lot more about it. Here we have just the bare essentials for protecting your website to prevent public access to your course work .
To access FTP software:
1. Select Start ->Programs->WS_FTP Professional->Ipswitch WS_FTP Professional 2007
2. On the left side, navigaate to to the H drive
3. On the righe side select do the following:
- Select: Connect to Remote Server
- Choose: Create Site
- Name it: beast.tcnj.edu
- Choose: Next
- Choose: FTP
- Type: beast.tcnj.edu
- Choose: Next
- Type your user name and password
- Choose: Next
- Choose: Finish
- Open to your www folder
- Open the folder you want to password protect.
4. Highlight the .htaccess file on the left side and click the arrow that points to the right. -> and you should see the .htaccess.txt file on the right side in the appropriate folder.
5. Click on the file on the right in such a way the you can edit the name of the file and remove the .txt from the end of the file.
6. Exit the FTP software and create the .users file.