Password Protection
You can only password protect a folder, not an individual page. However, each web page you place in the protected folder will also be password protected. For each instance, you will create a username and a password. Note that you can create multiple usernames and passwords for each folder.
For this tutorial, I am assuming that you have used SSH before and am comfortable creating new folders using SSH and transferring files using SSH.
1. In SSH, create a folder in you www folder you want to password protect. I created a folder called "password_protected."
2. In SSH, create a folder at the /home/stuart level called "web_passwords." Note that you do not want to create the "web_passwords" folder in the www level.
3. In WordPad, create a file called .htaccess (note the dot at the beginning) with the following information. When users try to access a password-protected page, the server will reference this folder to protect the web site.
AuthType Basic
AuthName "Restricted Web Site"
AuthUserFile /usr/home/stuart/web_passwords/example_web_pass_file
Require valid-user
Replace "stuart" with your username.
You can also change "Restricted Web Site" to whatever you want. This will pop up when someone tries to access your password-protected web site.
Note that "example_web_pass_file" is a file that will be created in step 6.
Save it as .txt file and call it .htaccess (again, note the dot at the beginning). Save it to your local machine, either in a defined folder, on the C Drive, or even on your Desktop.
4. On the local side of SSH, delete the .txt extension from the .htaccess file you just created.
5. Transfer the .htaccess file to the "password_protected" folder on the /home/stuart/www level.
6. If not already open, open a new terminal in SSH (Window > New Terminal). In the command line of SSH, type this:
htpasswd -c /usr/home/stuart/web_passwords/example_web_pass_file quiz1
Once again, remember to change "stuart" to your username.
The -c creates the "example_web_pass_file." You can change "quiz1" to whatever username you want users to type in for the password.
Hit Enter
7. You will be prompted to type the password in that you want your users to use. Hit enter and you will have to re-enter the password.
8. To add another username and password, type htpasswd /usr/home/stuart/web_passwords/example_web_pass_file quiz2. Note that there is no -c. Also note that I changed the username to "quiz2" You will then be prompted to type in another password twice.
9. Browse to your password protected folder on the Internet to test it out.