[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[cobalt-users] RAQ550: HOW TO Password Protect directory with .htaccess
- Subject: [cobalt-users] RAQ550: HOW TO Password Protect directory with .htaccess
- From: "John D. Gorena" <Support@xxxxxxxxxxxxxxxxxxx>
- Date: Thu Nov 14 09:57:02 2002
- Organization: http://www.JMG-Enterprises.com
- List-id: Mailing list for users to share thoughts on Sun Cobalt products. <cobalt-users.list.cobalt.com>
As stated in a previous writing "Raq550: A quick review - I feel like a
crash test dummy", that I would write a quick How-to for each part of
the Raq550 as I get the problems worked out. The main purpose of this
writing is for the archives so that newbies can find it easier in one
place. (Also, I hope that Sun/Cobalt will start adding help examples in
their manuals some day. Maybe this can be a good start?)
I hope this helps you,
John, Support@xxxxxxxxxxxxxxxxxxx
p.s. Maybe someone in the group can write a quick ASP or PHP file to
allow the administrators of each domain to make their own password
directories without allowing them to telnet or SSH. If so please send
me a copy. - John
RAQ550: HOW TO Password Protect directory with .htaccess
Below, you will find five examples on how to protect a directory with
login/password. The first four use system defaults for administrators
and users and the fifth example is to set a specific login and
password. All the examples require you to create a file called
".htaccess" with the example information. I use "pico .htaccess" in the
directory to create the file.
1 =============================
#Allows administrators of a particular domain to access
#the directory. In this case Site2.
#Access file
order allow,deny
allow from all
require group site2
Authname "Login Name for Access"
Authtype Basic
AuthAuthoritative off
AuthPAM_Enabled on
2 =============================
#ALL users on the RAQ550 can access this directory.
#Access file
order allow,deny
allow from all
require valid-user
Authname "Login Name for Access"
Authtype Basic
AuthAuthoritative off
AuthPAM_Enabled on
3 =============================
#FOR ALL SITE ADMINs for all domains
#Access file
order allow,deny
allow from all
require group site-adm
Authname "Login Name for Access"
Authtype Basic
AuthAuthoritative off
4 =============================
# Only user with userid from the domain
#Access file
order allow,deny
allow from all
require user userid
Authname "Login Name for Access"
Authtype Basic
AuthAuthoritative off
AuthPAM_Enabled on
5 =============================
SPECIFIC LOGIN AND PASSWORD:
For this example, we will show how to password protect a directory with
a specific login and password. You can apply this procedure to virtual
sites also by changing the directories.
a. Telnet in, and login as the User or admin or root
b. Navigate to the directory you want to password protect.
c. Create the .htaccess file in the directory (example: pico
.htaccess), it should contain the following lines:
# Access file
order allow,deny
allow from all
require valid-user
Authname "DirectoryName"
AuthPAM_Enabled off
Authtype Basic
AuthUserFile /home/sites/sitename/web/directory/.htpasswd
Replace "DirectoryName" with anything that you want - if you want.
Replace sitename and directory as appropriate.
Now you must create the .htpasswd file using the htpasswd tool.
a. Type the following command to create the file and add a user:
b. /usr/bin/htpasswd -c .htpasswd username
c. You will be prompted for the users' password twice. If you need
to add additional users to the file, use the command above without the
-c.
END