96.11 Password Protect Web Files
You can do this either on a per directory basis in
/etc/apache/httpd.conf or through the use of a
.htaccess file in the directory containing the files to
protect. The following is either added to a <Directory>
directive in /etc/apache/httpd.conf or into
.htaccess in the relevant directory.
AuthUserFile /home/kayon/public_html/.htpasswd
AuthGroupFile /dev/null
AuthName ByPassword
AuthType Basic
Require user kayonThen create the password file:
You will be prompted for a password. This stores the encrypted
password in the file .htpasswd (the -c option says to
create the file). You can manually edit this file, keeping the same
format, and perhaps even cutting the user passwords from
/etc/shadow to maintain the same passwords.
Note that you should take precautions to protect the actual encrypted passwords if you copy them from the shadow file (otherwise they may be subject to attempts to crack them). For example:
Protecting a cgi-bin directory through the use of the .htaccess
file make sure you have in /etc/apache-ssl/httpd.conf:
Normally this is set to None. That is, in
/etc/apache-ssl/httpd.conf you should have something like:
Your donation will support ongoing availability and give you access to the PDF version of this book. Desktop Survival Guides include Data Science, GNU/Linux, and MLHub. Books available on Amazon include Data Mining with Rattle and Essentials of Data Science. Popular open source software includes rattle, wajig, and mlhub. Hosted by Togaware, a pioneer of free and open source software since 1984. Copyright © 1995-2022 Graham.Williams@togaware.com Creative Commons Attribution-ShareAlike 4.0