-->

添加上htpasswd的用户(Adding a user on .htpasswd)

2019-08-08 18:54发布

我使用.htpasswd密码保护某个目录我的服务器上。 然而,我注意到,每次我这样做sudo htpasswd -c /etc/apache2/.htpasswd newuser我的当前内容.htpasswd将被覆盖。 我的网站的每个目录上htpasswd的自己的用户。

我怎么能不覆盖,而不是添加新用户对我的.htpasswd

Answer 1:

Exact same thing, just omit the -c option. Apache's docs on it here.

htpasswd /etc/apache2/.htpasswd newuser

Also, htpasswd typically isn't run as root. It's typically owned by either the web server, or the owner of the files being served. If you're using root to edit it instead of logging in as one of those users, that's acceptable (I suppose), but you'll want to be careful to make sure you don't accidentally create a file as root (and thus have root own it and no one else be able to edit it).



Answer 2:

FWIW, htpasswd -n username都将输出结果直接输出到标准输出,并完全避免接触文件。



文章来源: Adding a user on .htpasswd