htpasswd -c /var/www/ user1

If you already have the .htpasswd file and would like to append a new user, repeat the command with the “-c”

htpasswd /var/www/ user2

.htpasswd is the standard file name that contains the authentication credentials, but you can actually call it whatever you want as long as you reference it in the .htaccess file:

AuthName "Restricted Area"
AuthType Basic
AuthUserFile /var/www/
AuthGroupFile /dev/null
require valid-user

Generate htaccess password (htpasswd) from the command line - Gaslamp Media


Leave a Reply