LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > General
User Name
Password
General This forum is for non-technical general discussion which can include both Linux and non-Linux topics. Have fun!

Notices


Reply
  Search this Thread
Old 05-04-2003, 12:52 PM   #1
darin3200
LQ Guru
 
Registered: Dec 2002
Distribution: Gentoo!
Posts: 1,153

Rep: Reputation: 45
HTML password protecting


I am making my website and I want to know if there is a way to password protect an html site so everyone can see the index of the site. Then I can have a link called "darin's stuff" and if someone clicks on it they will be prompted for a password, but I of course know the password.
 
Old 05-04-2003, 01:05 PM   #2
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 79
Yes you can use a ".htaccess" file. To protect a directory so you can put all your files that are to be protected in that directory.

1) You will need "options AuthConfig" turned on in httpd.conf for that directory.
2) Your ".htaccess" file should be put in the directory too be protected and should look like:
Code:
AuthUserFile /path/to/.htpasswd
Authname "Darin's stuff - No unauthorised access"
Authtype Basic
require valid-user
3) Create ".htpasswd" with a username and password pair(s) like:
Code:
darin:kcYriND57b.vI
In this example the password is "password".
 
Old 05-04-2003, 01:25 PM   #3
darin3200
LQ Guru
 
Registered: Dec 2002
Distribution: Gentoo!
Posts: 1,153

Original Poster
Rep: Reputation: 45
so here is my index so far
Code:
<html>
<head>
  <meta http-equiv="content-type"
 content="text/html; charset=ISO-8859-1">
  <title>index</title>
</head>
<body>
<div style="text-align: center;"><br>
<br>
<a href="1.html">darin's stuff</a><br>
<br>
<br>
<br>
</div>
</body>
</html>
and here is darin's stuff if I had my username be darin and my password test
Code:
AuthUserFile /path/to/.htpasswd
Authname "Darin's stuff - No unauthorised access"
Authtype Basic
require valid-user
darin:test
<html>
<head>
  <meta http-equiv="content-type"
 content="text/html; charset=ISO-8859-1">
  <title>1</title>
</head>
<body>
Darin's Stuff<br>
</body>
</html>
is this right???
(thanks for the quick response )
 
Old 05-04-2003, 01:27 PM   #4
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 79
Not in the slightest. Did you only read every third word of post 2?
 
Old 05-04-2003, 01:29 PM   #5
trickykid
LQ Guru
 
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 269Reputation: 269Reputation: 269
Quote:
Originally posted by darin3200
so here is my index so far
Code:
<html>
<head>
  <meta http-equiv="content-type"
 content="text/html; charset=ISO-8859-1">
  <title>index</title>
</head>
<body>
<div style="text-align: center;"><br>
<br>
<a href="1.html">darin's stuff</a><br>
<br>
<br>
<br>
</div>
</body>
</html>
and here is darin's stuff if I had my username be darin and my password test
Code:
AuthUserFile /path/to/.htpasswd
Authname "Darin's stuff - No unauthorised access"
Authtype Basic
require valid-user
darin:test
<html>
<head>
  <meta http-equiv="content-type"
 content="text/html; charset=ISO-8859-1">
  <title>1</title>
</head>
<body>
Darin's Stuff<br>
</body>
</html>
is this right???
(thanks for the quick response )
I don't think your quite following. The setup for htaccess doesn't take place in the actual html of the page. You need to setup your httpd.conf file with those parameters along with an actual .htpasswd file and such. You should read up on the docs for htpasswd at www.apache.org for more information.
 
Old 05-04-2003, 01:29 PM   #6
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 79
You need to proect a whole directory eg:
http://yoursite.com/private/

".htaccess" and ".htpasswd" are files in their own right.
 
Old 05-04-2003, 03:18 PM   #7
darin3200
LQ Guru
 
Registered: Dec 2002
Distribution: Gentoo!
Posts: 1,153

Original Poster
Rep: Reputation: 45
Argg

I get it. i did a google for .htaccess and found a lot more useful stuff than when I did html passwords. I was trying to see if I could just password protect a directory and uploaded .htaccess and .htpasswd into a directory. I need to change some stuff now and I go to delete the directory that I made and gftp says I can't because it is not empty. I went into it to get rid of the .htaccess and .htpassed files but I don't see them. How do I get them off? Ahh the joys of html ineptness
 
Old 05-04-2003, 03:22 PM   #8
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 79
You can't see them because they are hidden (they start with a ".") You need to invoke the ls command with a "-a" argument eg:
ls -a
 
Old 05-04-2003, 03:24 PM   #9
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 79
Sorry - you are using gftp - you need to:
1) Open gftp
2) "FTP" menu -> "Options"
3) Check the show hidden files box.
 
Old 05-04-2003, 03:33 PM   #10
darin3200
LQ Guru
 
Registered: Dec 2002
Distribution: Gentoo!
Posts: 1,153

Original Poster
Rep: Reputation: 45
Here is a screenshot of gftp. I have it selected to show hidden files but as you can see at the bottom it won't let me delete the directory I am in at the right.
 
Old 05-04-2003, 03:43 PM   #11
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 79
You will still need to delete the files first and I think the key to your problem can be seen in the second line of the log - it is loading the file list from cache. Try refreshing the file listing.
 
Old 05-04-2003, 03:50 PM   #12
darin3200
LQ Guru
 
Registered: Dec 2002
Distribution: Gentoo!
Posts: 1,153

Original Poster
Rep: Reputation: 45
http://frontiernet.net/~darinf/snapshot2.png
 
Old 05-04-2003, 03:55 PM   #13
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 79
I'm not quite sure what you are showing me. There are no files there - the .htaccess file should be in the subfolder.
 
Old 05-04-2003, 04:00 PM   #14
darin3200
LQ Guru
 
Registered: Dec 2002
Distribution: Gentoo!
Posts: 1,153

Original Poster
Rep: Reputation: 45
everytime I try to delete folder 2, it gives me a "directory not empty" and I can't see any folders in the directory. I put my .htaccess and .htpasswd files in there but they don't show up
 
Old 05-04-2003, 04:09 PM   #15
Kurt Weber
Member
 
Registered: Mar 2003
Location: Princeton, IN, USA
Distribution: Slackware
Posts: 48

Rep: Reputation: 15
Quote:
Originally posted by darin3200
everytime I try to delete folder 2, it gives me a "directory not empty" and I can't see any folders in the directory. I put my .htaccess and .htpasswd files in there but they don't show up
That's because you're ignoring what people tell you.
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Password protecting a directory? How? Thrifty Linux - Security 7 07-20-2004 08:25 PM
Password Protecting Web Sites ChrisDiG Linux - Software 1 11-01-2003 08:53 AM
Protecting Root Password ukndoit Linux - Security 10 10-16-2003 09:32 AM
password protecting directories jayakrishnan Linux - General 2 02-10-2003 05:49 AM
password protecting a webpage jonfa Linux - General 5 03-22-2002 06:26 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > General

All times are GMT -5. The time now is 04:54 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