Grove
Creating Your Own Username and Passwords
At your discretion, you may assign individual
usernames associated with a unique password.
As a security measure, it is important
not to place
this file in the
public_html directory or its subdirectories. The
path to your file
mypassfile generally should be located in the
home directory of your account.
Creating password files
To generate the password file you need to run the password encryption
program
htpasswd. For example, if you wanted to create the file
mypass
containing the name
linda to be associated with the password
computerclassmate, you would type the following:
- cd ~
- htpasswd -c mypassfile aperson
You will be prompted to enter the password
for
aperson. You would enter:
computerclassmate
and then repeat it for verification.
After creating the file, make sure it's readable by others:
Note: The
-c is used only to create the
mypassfile
file; you may only create one username associated with a password
at each processing of
htpasswd.
Password information to include in the .htaccess file
The
.htaccess file will need password file information. In
addition, authorization control
needs to be specified. Use the following lines in your
.htaccess
file to restrict access to you web pages to names in your
mypassfile
that have an associated password. In this example,
the owner of the class account
c4321brw for course
bus4321 will
restrict access to his web pages to allow only the authorized usernames with the required password.
The information for validating the username and password
is in the file
mypassfile in the
c4321brw home
directory.
- AuthType Basic
- AuthName your-web-username
- AuthUserFile /class/bus4321/c4321brw/mypassfile
- require valid-user
Password access control adding group information
If you are interested in setting up group associations, you need to create
an additional file,
allmygroupfile,
to hold your group names and their associated usernames. No
information in the
allmygroupfile is encrypted. Again for
security reasons, it is important
not to place this
file in the
public_html directory or its subdirectories. The path
to your file
allmygroupfile generally would be located in your
home directory of your account.
To generate the groupfile,
webgroups, use
- cd ~
- cat > webgroups
- cis5331: roy tony nancy
- group2: bear dog
- group3: calculus
After creating the file, make sure it's readable:
In the following example, the username for the account is
jason.
He has created a password file in his home directory named
mypassfile
using the
htpasswd command. In addition he has created a file,
webgroups,
associated with usernames who have encrypted passwords contained in
mypassfile.
The AuthName is
Computer classes. The group that will have access
to jason's web pages are groups
cis5331 and
group2.
- AuthType Basic
- AuthName "Computer classes"
- AuthUserFile /home/jason/mypass
- AuthGroupFile /home/jason/webgroups
- require group cis5331 group2
Note: By using these last two
examples, someone trying to browse jason's web pages would have the
username
roy, tony nancy bearor
dog and have the correct associated
password.
AuthName "Computer classes"
AuthName strings
MUST be
quoted in .htaccess if they contain blank characters (like spaces).
For example, if you use an AuthName directive like this:
AuthName This and That
you will need to change it to:
AuthName "This and That"
If you are interested in further information on security on the apache
web server refer to
apache.org.