cancel
Showing results for 
Search instead for 
Did you mean: 

Password protect - CGI server path?

Highlighted
deewhyplus
Newbie
Posts: 2
Registered: 17-06-2010

Password protect - CGI server path?

Sorry if this has been covered before but I seem to be going in circles searching for it.
I need to password protect a test site in a folder on the CGI server (it should be hidden until it's finished). I was attempting to follow these instructions about htaccess/htpasswd: http://community.plus.net/forum/index.php/topic,43047.0.html
I know nothing about Telnet and very little about scripting so please bear with me.
Telnet method
I used Terminal (I'm on Mac OS X). Neither 'telnet cshell.plus.net' or 'telnet cgi.plus.net' seem to work. I eventually get messages like this:
Trying 84.92.1.4...
telnet: connect to address 84.92.1.4: Connection refused
telnet: Unable to connect to remote host
[Process exited - exit code 1]
I found some messages saying Telnet had been disabled last year so I don't know if the above is still current?

Script method
I found this message...
Quote
Andrew B said:
March 29th, 2010
Hi Ratbag, the easiest way to get the path for the CGI server is to run a php script containing the following command:
< ?php
Print getcwd();
?>
I'll add this to the guide soon.

I saved the above PHP code into a file, called it cgipath.php and uploaded it to my CGI space but I couldn't get it to work in my browser. Got this instead:
Server error!
The server encountered an internal error and was unable to complete your request.
Error message:
Premature end of script headers: cgipath.php
If you think this is a server error, please contact the webmaster.
Error 500

The server path seems like a fairly simple thing to find out so where am I going wrong? And is there a more straightforward guide that I'm missing? Sorry if there is but the help pages seem to be a bit of a labyrinth.
4 REPLIES
Community Veteran
Posts: 1,850
Registered: 11-08-2007

Re: Password protect - CGI server path?

i'm pretty sure telnet is deprecated.  can you not ssh into the site?  a bsd forum might offer some help.  mac os x is based on bsd, as far as i know.
Community Gaffer
Community Gaffer
Posts: 12,999
Thanks: 784
Fixes: 70
Registered: 04-04-2007

Re: Password protect - CGI server path?

Quote from: artificer
i'm pretty sure telnet is deprecated.  can you not ssh into the site?

Both telnet and SSH access are disabled.
Quote from: deewhyplus
Script method
I found this message...
Quote
Andrew B said:
March 29th, 2010
Hi Ratbag, the easiest way to get the path for the CGI server is to run a php script containing the following command:
< ?php
Print getcwd();
?>
I'll add this to the guide soon.

I saved the above PHP code into a file, called it cgipath.php and uploaded it to my CGI space but I couldn't get it to work in my browser. Got this instead:
Server error!
The server encountered an internal error and was unable to complete your request.
Error message:
Premature end of script headers: cgipath.php
If you think this is a server error, please contact the webmaster.
Error 500

You need to make sure your file permissions are correct. I think they default to 640 (-rw-r-----). Try changing the permissions of the cgipath.php file to 700 (-rwx------) instead.

Bob Pullen
Plusnet Products Team
If I've been helpful then please give thanks ⤵

deewhyplus
Newbie
Posts: 2
Registered: 17-06-2010

Re: Password protect - CGI server path?

Thanks to Bob I'm past that hurdle but now I've hit another one.
I get my filepath as "/share/storage/01/us/username" (obviously with my real username). Putting that in the htaccess file with the directory at the end doesn't seem to work. I tested it and got straight into the page - no prompt for a password.
Should something like "htdocs" or another folder go in the filepath? I noticed the link to the directory has my username repeated - is that anything to do with it? URL format is "http://ccgi.username.plus.com/~username/directory/"
Encrypted password generator
The link to the generator in the htaccess guide (as above) brings up a page but it didn't seem to actually work when I tried it. I found a working one at http://shop.alterlinks.com/htpasswd/htpasswd.php.
The guide also says "a tool now exists that can create your .htpasswd file entries for you" but it doesn't seem to exist any more - it was a dead link.
Any chance of that guide being updated so I don't have to bother folk with so many questions?
Superuser
Superuser
Posts: 9,138
Thanks: 546
Fixes: 46
Registered: 06-04-2007

Re: Password protect - CGI server path?

Password protecting a directory on CCGI works OK for me.
The procedure I used is that described in the Community Support Library article how to password protect your website but adapted for CCGI rather than homepages.
The path to the password file in .htaccess needs to be something like
/share/storage/01/us/username/folderpath/.htpasswd
replacing 01, us, username and folderpath with values appropriate for yourself. Running
<?php
print getcwd();
?>
on ccgi with chmod permissions set to 700 will give the path to use.
I used the htpassword manager tool on our UserTools site to generate the encrypted loginname:password string to go in .htpasswd. Permissions for .htaccess and .htpasswd need to be 640 (the server has to read them).
David