Adding a user to .htpasswd

I use .htpasswd to protect a specific directory on my server. However, I noticed that every time I do this, sudo htpasswd -c /etc/apache2/.htpasswd newuser my current sudo htpasswd -c /etc/apache2/.htpasswd newuser contents will be overwritten. Each directory on my site has its own user .htpasswd.

How can I not overwrite to add a new user to my .htpasswd instead?

+54
apache .htpasswd
Jan 30 '13 at 2:01
source share
2 answers

Same thing, just omit the -c option. Apache documents on it here .

htpasswd /etc/apache2/.htpasswd newuser

In addition, htpasswd does not usually start as root. It usually belongs to either the web server or the file owner. If you use root to edit it instead of logging in as one of these users, this is acceptable (I suppose), but you'll want to be careful to make sure that you don't accidentally create the file as root (and therefore have your own root, and no one can edit it).

+77
Jan 30 '13 at 2:03
source share

FWIW, htpasswd -n username prints the result directly to stdout and does not touch files at all.

+5
Feb 19 '15 at 19:53
source share



All Articles