Gossamer Forum
Home : General : Perl Programming :

HOW to use .htpasswd ???? show me please?

Quote Reply
HOW to use .htpasswd ???? show me please?
I dont really know what s going on about .HTPASswd thing.. HOW TO use to protect the admind.cgi?? please help
Quote Reply
Re: HOW to use .htpasswd ???? show me please? In reply to
 http://faq.web2010.com/htaccess.htm

--mark

------------------
You can reach my by ICQ at UID# 8602162

Quote Reply
Re: HOW to use .htpasswd ???? show me please? In reply to
Here is a script that makes it easier.
Code:
#!/usr/bin/perl
##########################################################################
#
# makeht.cgi
# Directions:
# Upload makeht.cgi to the directory you want to protect.
# Chmod to 755
# Run makht.cgi with your browser
# http://yoursite.com/protecteddirectory/makeht.cgi?username/password
# Your directory is now protected.
#
##########################################################################

print "Content-type:text/html\n\n";
eval '$home = (getpwuid($< ))[7];';
if (!-e "C:/") {
$pwd = `pwd`; chop $pwd;
}
if (!eval 'use Cwd;') {
eval '$cwd = cwd();';
} else {
$cwd = "";
}
($uname, $pword) = split(/\//,$ENV{'QUERY_STRING'});
if ($pwd eq "") {
$dirname = $cwd;
} else {
$dirname = $pwd;
}
if ($dirname eq "") {
&dienice("Error determining directory");
}
if ($uname eq "") {
&dienice("Error determining username");
}
if ($pword eq "") {
&dienice("Error determining password");
}
$cpass = crypt ($pword ,"Cd");
open (HTACC,">.htaccess") or &dienice("Error opening htaccess");
print HTACC qq~AuthName Links Admin
AuthType Basic
AuthUserFile $dirname/.htpasswd
require valid-user
~;
close(HTACC);
open (HTPWD,">.htpasswd") or &dienice("Error opening htpasswd");
print HTPWD "$uname:$cpass\n";
close(HTPWD);
print "Complete. Username: $uname Password: $pword Encrypted Password: $cpass";
sub dienice {
($msg) = @_;
print "<h2>Error</h2>\n";
print $msg;
exit;
}

------------------
JRM Studios http://www.jrmstudios.com
The Hotrodding Network http://www.jrmstudios.com/hotrodding
Quote Reply
Re: HOW to use .htpasswd ???? show me please? In reply to
How Do You Use it though???

Save the file as Make.cgi

Then RUN it on the server?...

How to use please?
Quote Reply
Re: HOW to use .htpasswd ???? show me please? In reply to
Name it makeht.cgi
Put it in the dir you want to protect.
type http://yoursite.com/protecteddirectory/makeht.cgi?username/password in your browser.

Replace "yoursite.com/protecteddirectory" with the location of the file

Replace "username" with your user name.
Replace "password" with your password.

That's it.


------------------
JRM Studios www.jrmstudios.com
The Hotrodding Network www.jrmstudios.com/hotrodding
Quote Reply
Re: HOW to use .htpasswd ???? show me please? In reply to
Oh Man.

I set the username as usename
and password as pw....

can u help u how to change it please

thanks
Quote Reply
Re: HOW to use .htpasswd ???? show me please? In reply to
Just delete the .htaccess and .htpassword files with your FTP program. Then do it again.

------------------
JRM Studios www.jrmstudios.com
The Hotrodding Network www.jrmstudios.com/hotrodding
Quote Reply
Re: HOW to use .htpasswd ???? show me please? In reply to
do you have to create the .htaccess & .htpasswd files before you run the script?
Quote Reply
Re: HOW to use .htpasswd ???? show me please? In reply to
The script creates them.

------------------
JRM Studios www.jrmstudios.com
The Hotrodding Network www.jrmstudios.com/hotrodding
Quote Reply
Re: HOW to use .htpasswd ???? show me please? In reply to
NO, you DO NOT!

Just copy the script he gave us...
then upload to the dir. you want to protect

and type as

http://www.YOURNAME.com/admin/protect.cgi?username/password

username = your name
password = your password

protect.cgi = if you save your scipt as protec.cgi else change it to whatever you name it...

good luck
Quote Reply
Re: HOW to use .htpasswd ???? show me please? In reply to
I have done exactly as you say but everytime I run the script I get this
"Error opening htaccess"
Quote Reply
Re: HOW to use .htpasswd ???? show me please? In reply to
As You SERVER Administrator.

I uploaded to mine

and I typed

http://www.MYNAME.net/cgi-bin/admin/pro.cgi?MYNAME/MYPASSWORD

and I hit enter, it crypted and no one can see.

I dont know what happened, try to install to another dir to see if it work or not...

good luck again
Quote Reply
Re: HOW to use .htpasswd ???? show me please? In reply to
Try changing your directory permissions to all-writable. "chmod 777 directoryname"
Quote Reply
Re: HOW to use .htpasswd ???? show me please? In reply to
trijason just get the file manager script on this site. I does lots of things, even password protection.

------------------
Patrick Chukwura
http://nytesoft.hypermart.net