This is very simple.  For any file you want to have its own password protection, create an .htaccess file in the folder the file resides.  Just replace “pagename.html” for the file.  Then, just go to our .htpasswd password generator and create the .htpasswd file in the format:  username:password, where username is the name required to log in and “password” is the encrypted version of the password that shows in the tool in the link above under “Create new .htpasswd password file” and be sure to save your .htpasswd file in the absolute server path to the .htpasswd file.

AuthUserFile /home/user/path/to/.htpasswd
AuthName "name of login prompt"
AuthType Basic
<files “pagename.html”>
require valid-user
</files>

One more note, you don’t need to save the “.htpasswd” file by this name, any name will do.  Learn a lot more about .htaccess by visiting the official Apache website.  I like to put the commonly used snippets and tips on my site so they’re easy to find for me later.

–  Aaron Belchamber
www.AaronBelchamber.com


Trying to putty into your server, you may get a “Connection Refused” error.  That’s usually because the Open SSH server and client aren’t installed, just run this at the command line and restart Apache.

sudo apt-get install openssh-server openssh-client