Subject: htpasswd Command
Author: AwsEC2
In response to: Protect Apache web resources with directive defined in configuration file
Posted on: 09/11/2012 08:26:39 PM
You can manage user and password pairs by utility command 'htpasswd':
Syntax:
htpasswd [-c] <.htpasswd> <user_name>
Here the option '-c' stands for '-create' to create a new file.
Example:
# htpasswd -c /usr/local/awstats/wwwroot/.awstats.pwd John
New password: ***
Re-type new password: ***
Adding password for user John
>
> On 09/11/2012 08:01:21 PM
AwsEC2 wrote:
Alternatively, if you are administrator, you can place any access rules inside the directory directive in the configuration file /etc/httpd/conf/httpd.conf or /etc/httpd/conf.d/*.conf.
Sample directive defined in /etc/httpd/conf/httpd.conf:
<Directory /usr/local/awstats/wwwroot/cgi-bin>
AuthType Basic
AuthName "AWStats - Web, FTP, and Mail Statistics"
AuthUserFile /usr/local/awstats/wwwroot/.awstats.pwd
Require valid-user
</Directory>
Sample directive defined in file under /etc/httpd/conf.d:
$ cat /etc/httpd/conf.d/awstats.conf
<Directory /usr/local/awstats/wwwroot/cgi-bin>
AuthType Basic
AuthName "AWStats - Web, FTP, and Mail Statistics"
AuthUserFile /usr/local/awstats/wwwroot/.awstats.pwd
Require valid-user
</Directory>
References: