Gossamer Forum
Home : Products : Links 2.0 : Installation -- Unix :

.Htpasswd? No telnet access.

Quote Reply
.Htpasswd? No telnet access.
hi,
I need help.
I want password protect my admin directory with .Htaccess and ht.passwd.,but my hosting provider don`t allow telnet access to the Apache server for htpasswd commands.
How can I protect my directory?
thanks.james

Quote Reply
Re: .Htpasswd? No telnet access. In reply to
Manually create the .htaccess file.

Use the .htaccess example here:

http://he.net/...o/htaccess/demo.html

Put the code below into a cgi file and upload it to your server in the directory you want to create the .htpasswd file, chmod it to 755 and execute it.

Code:
#!/usr/bin/perl

&main();

sub main {

my $password = "password";
my $username = "username";
my $new = crypt($password, "salt");

open(PWD,">.htpasswd") || die "Couln't create .htpasswd file : $!";
print PWD "$username:$new\n";
close(PWD);

print "Content-type: text/plain\n\n";
print "DONE";
}
Obviously alter "password" and "username".

The password is encrypted using crypt - it isn't the most secure way but it is good enough for what you want.



Installations:http://www.wiredon.net/gt/
Favicon:http://www.wiredon.net/favicon/

Quote Reply
Re: .Htpasswd? No telnet access. In reply to
hi,
thanks.
I get a internal server error when I try to execute the cgi in the server.
the perl path is right.


Quote Reply
Re: .Htpasswd? No telnet access. In reply to
You need to use;

#!/usr/bin/perl
&main();

sub main {

my $password = "password";
my $username = "username";
my $new = crypt($password, "salt");
open(PWD,">.htpasswd") || die "Couln't create .htpasswd file : $!";
print PWD "$username:$new\n";
close(PWD);print "Content-type: text/plain\n\n";
print "DONE";

}

There was an extra ) where there shouldn't have been Wink

Andy

webmaster@ace-installer.com
http://www.ace-installer.com
Quote Reply
Re: .Htpasswd? No telnet access. In reply to
Ack, sorry I added a bracket by accident...

Change

open(PWD,">.htpasswd") || die "Couln't create .htpasswd file : $!");

to

open(PWD,">.htpasswd") || die "Couln't create .htpasswd file : $!";

Installations:http://www.wiredon.net/gt/
Favicon:http://www.wiredon.net/favicon/

Quote Reply
Re: .Htpasswd? No telnet access. In reply to
I get "done" from the script,but my admin directory is not password protection.
Maybe My .htaccess file is wrong.
I use windows wordpad to write it with extension .txt.I uploaded it in my cgi-bin directory.
thanks for your help again.

Quote Reply
Re: .Htpasswd? No telnet access. In reply to
The file HAS to be called just .htaccess - not .htaccess.txt

Use your FTP client to rename it. It should then disappear from sight.

Installations:http://www.wiredon.net/gt/
Favicon:http://www.wiredon.net/favicon/

Quote Reply
Re: .Htpasswd? No telnet access. In reply to
I`ve just renamed it as .htaccess,but now i get internal server error web i try to execute my admin.cgi.

Quote Reply
Re: .Htpasswd? No telnet access. In reply to
That means you have setup .htaccess incorrectly. Try double chcking the paths. Maybe you could place a copy of what you have in your .htaccess file here so we could have a look.

Andy

webmaster@ace-installer.com
http://www.ace-installer.com
Quote Reply
Re: .Htpasswd? No telnet access. In reply to
You would be better just finding a free script such as LockIt at hotscripts.com to do everything for you.

Installations:http://www.wiredon.net/gt/
Favicon:http://www.wiredon.net/favicon/

Quote Reply
Post deleted by PaulWilson In reply to
Quote Reply
Re: .Htpasswd? No telnet access. In reply to
I didn't. I poseted it saying that I thought it was to do with .htaccess files not being set correctly, but after i posted it i read it again and realised that it wasn't down to that. So, I went back and changed it. I didn't realise you had mad a reply to the error until i refreshed the page again!


NOTE: In case you are wondering what I am on about, Paul accused me in the above post of 'copying' him with my reply. He said that I had made a post, then seen his and changed it to say exactly the same thing. Since then, he has removed the post Smile

Andy

webmaster@ace-installer.com
http://www.ace-installer.com
Quote Reply
Re: .Htpasswd? No telnet access. In reply to
hi,Thanks a lot.It works now.
I have an extra space in the .htaccess file.
james.

Quote Reply
Re: .Htpasswd? No telnet access. In reply to
I have the same problem and have been following this thread.

I copied the code you provided, changed the password and username, saved it as htacess.cgi (using homesite), uploaded it, chmodded to 755, changed it's name to .htaccess.

It disappeared. I have tried this a couple of times with slight variations - there must be a good few lost .htaccess files floating about now! But when I go to admin.cgi I am still not protected and the warning is still there.

Am I missing something here - do I need to create a .htpassword file or something?

Quote Reply
Re: .Htpasswd? No telnet access. In reply to
I never said upload the code in a file called htaccess.cgi and rename it to .htaccess

I said put it in the directory that you want to create the .htpasswd file and execute the code which will create the .htpasswd file for you.

Installations:http://www.wiredon.net/gt/
Favicon:http://www.wiredon.net/favicon/