LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 03-20-2002, 11:41 PM   #1
jonfa
Member
 
Registered: Mar 2001
Location: FL
Posts: 257

Rep: Reputation: 30
password protecting a webpage


Hi All,

I am running Redhat 7.2 and currently have a website on my machine in (/var/www/html/index.html...). What I want to do is password protect a webpage within my website and not the entire page. Is this possible? Any Ideas? Thanks.

Jon
 
Old 03-20-2002, 11:53 PM   #2
jayakrishnan
Member
 
Registered: Feb 2002
Location: India
Distribution: Slacky 12.1, XP
Posts: 992

Rep: Reputation: 30
use .htaccess

Put the secret file(s) in a directory, and use .htaccess file to protect that directory
 
Old 03-21-2002, 12:32 AM   #3
jonfa
Member
 
Registered: Mar 2001
Location: FL
Posts: 257

Original Poster
Rep: Reputation: 30
Thanks for the reply. Here's what I did:

1. created /var/www/html/protected/ (where "protected" is the directory where my files will be)

2. created a test webpage in the protected directory and did: chmod a+r filename.html

3. created .htaccess file in the protected directory and added the following :
AuthName "Enter Password"
AuthType Basic
AuthUserFile /root/password
require valid-user

4. I then did: chmod 755 .htaccess

5. Under /root I ran: "htpasswd -c password username" and "Chmod 755 password"

It didn't work. What am I missing? Thanks

Jon
 
Old 03-21-2002, 03:55 AM   #4
Mik
Senior Member
 
Registered: Dec 2001
Location: The Netherlands
Distribution: Ubuntu
Posts: 1,316

Rep: Reputation: 47
Well what you did is right. There is just one problem. In most cases apache is run as the user/group nobody/nogroup. So you'll have to give that user read permission to the password file. The /root directory is only for root so no other user can read files in that directory. So it would be best to put the password file in a different location and make sure that the user you run apache as has permission to at least read the password file.

Just another thing 755 isn't very safe for the password file. You might want to try something like:

chown root.nogroup passwordfile
chmod 640 passwordfile

Last edited by Mik; 03-21-2002 at 03:58 AM.
 
Old 03-21-2002, 11:25 AM   #5
jonfa
Member
 
Registered: Mar 2001
Location: FL
Posts: 257

Original Poster
Rep: Reputation: 30
Hi,

I moved the password file from /root to /home/someuser. I then executed the following:

chown root.apache passwordfile
chmod 640 passwordfile

Still no luck. Not sure if my "root.apache" is correct?

Jon
 
Old 03-22-2002, 06:26 AM   #6
Mik
Senior Member
 
Registered: Dec 2001
Location: The Netherlands
Distribution: Ubuntu
Posts: 1,316

Rep: Reputation: 47
What does it say in the httpd.conf file for User and Group? Mine says nobody and nogroup. That user should have permission to read your password file.

The commands I told you to run make the owner of the password file root and the group nogroup or in your case apache. Then the chmod gives the owner read and write permissions and the group only read permissions.

Since you put it into the directory /home/someuser then you would also have to make sure that the user that runs apache has read and execute rights in that directory.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Password protecting tar files jayakrishnan Linux - General 3 01-13-2008 11:02 PM
Password protecting a directory? How? Thrifty Linux - Security 7 07-20-2004 08:25 PM
Protecting Root Password ukndoit Linux - Security 10 10-16-2003 09:32 AM
HTML password protecting darin3200 General 19 06-03-2003 03:13 AM
password protecting directories jayakrishnan Linux - General 2 02-10-2003 05:49 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 08:18 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration