Marketplace:

 
Active-Venture.com: Cheap hosting for ecommerce and small business
Buy cheap domain registration with free domain search and forwarding services
Cheap domain registration: Register domain name and domain search services at affordable price

 

   

Password Protect Web Files

next up previous contents index

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 kayon


Then create the password file:



  $ cd public_html
  $ htpasswd -c .htpasswd kayon


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:



  # chown www-data.www-data .htpasswd
  # chmod o= .htpasswd


I would like to figure out a way to use the system passwords file without making /etc/shadow accessible to everyone (which is precisely the point of the shadow file) and without having to copy the encrypted passwords into .htpasswd. Then I would define the particular user group (AuthGroupFile) as the users who can actually access the relevent web pages.

Protecting a cgi-bin directory through the use of the .htaccess file make sure you have in /etc/apache-ssl/httpd.conf:



AllowOverride AuthConfig


Normally this is set to None. That is, in /etc/apache-ssl/httpd.conf you should have something like:



  <Directory "/home/kayon/projects/wwp/cgi-bin">
        Options None
        AllowOverride AuthConfig
        Order deny,allow
        Deny from all
        Allow from togaware.com
  </Directory>



next up previous contents index


Copyright (c) 1995-2004

 

      

Marketplace:
Facts: " How the mind works is still a mystery. We understand the hardware, but we don't have a clue about the operating system.   "  

Tuesday 7 February 2012 18:28:32 1328639312