Password Access
There are two types of passwords files, standard and DBM. Created by the
dbmpasswd program, DBM password files, are more efficient for use with
over a hundred usernames. For most cases, standard password files,
created with the htpasswd program, are the easiest to create and maintain.
Standard Password Files
Password files protect an entire directory. To create a password-protected file or group of files, put the files into a separate directory from your open public files. Create the password file in the protected directory using the htpasswd program as in the steps below.
- Create the initial password file
htpasswd -c password_file_name user_name
The -c option creates a new password file and
adds the user 'user_name' to the password file. A prompt
will then ask for the new user's password.
Example 'htpasswd -c .pass tom'
- Additional users can be added by using htpasswd again:
htpasswd password_file_name new_user_name
- Create a file with the name .htaccess (dot is required as the first character of the filename. Here is a sample .htaccess file:
AuthUserFile "/www/documents/cs/protected/.pass"
AuthGroupFile /dev/null
AuthName "access to the documents in this directory"
AuthType Basic
This .htaccess file will give a login prompt to any user who tries to open a file in the "protected" directory. The prompt will say "access to the documents in this directory" and it will ask for a username and password. The username and password will be verified against a file called .pass (note dot in first character of filename) which is also located in the /cs/protected directory.