Linux: .htaccess and .htpasswd files

You can use .htaccess to protect a directory on your Apache web server. Users trying to access a protected directory will be asked to enter a user and password. .htaccess defines the protected directory, and .htpassword stores your password hashes.

.htaccess normally looks like this:

AuthName "Title"
AuthUserFile /path-to-your-htpasswd-file/.htpasswd
AuthType Basic
require valid-user

To create a .htpasswd file:
htpasswd -c /path.to.the.folder.you.want.to.protect/.htpasswd <username>

or

htpasswd -c <username>

and you will be prompted to enter a password for <username>

Of course, you can use a .htpasswd generator. Remember, Google is your friend 🙂