This howto article shows you how to add a new user and password combination to a .htaccess file, for use with the Apache web server. This assumes the Apache tools are installed (specifically the ‘htpasswd’ utility).
In these examples, replace “testuser” and “Pass123” with the real username and password you wish to add.
(Note: if the .htpasswd file doesn’t already exist, either create it first, or add the -c parameter to htpasswd to automatically create it. If the file exists, and you use -c, it will overwrite the file instead of appending to it.)
Using crypt encryption:
htpasswd -bd .htpasswd testuser Pass123
Using MD5 encryption:
htpasswd -bm .htpasswd testuser Pass123
Using SHA encryption:
htpasswd -bs .htpasswd testuser Pass123