http://qs321.pair.com?node_id=289062

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I would like to have a CGI script to access my computer remotely. I would prefer to use Apache mod_perl, but using another server is ok. I just need a solution LIKE ssh, but it needs to run through HTTP (well, HTTPS probably) to get through the proxy at my school. I have attempted this, but I am having difficulties. (Personally, I think my script sucked.)

Thanks,
James (jamesl_89@yahoo.com)
  • Comment on Remote Administration using Apache mod_perl

Replies are listed 'Best First'.
Re: Remote Administration using Apache mod_perl
by sauoq (Abbot) on Sep 04, 2003 at 23:58 UTC

    Just run your sshd on one of the ports commonly used for web servers. Your school probably allows port 8080 for instance. Using CGI for administration isn't generally advisable.

    -sauoq
    "My two cents aren't worth a dime.";
    
Re: Remote Administration using Apache mod_perl
by pfaut (Priest) on Sep 04, 2003 at 23:47 UTC

    There lies untold security issues just waiting to be found by some malicious hacker! If you really need to remotely administer your machines, first look for existing software written by people who have tackled this with an eye towards proper security.

    If you really want to go ahead with this, it would be easier to help you if you would post some code.

    90% of every Perl application is already written.
    dragonchild
Re: Remote Administration using Apache mod_perl
by jaldhar (Vicar) on Sep 05, 2003 at 01:23 UTC

    If you must go the CGI route, webmin is a pretty complete solution and it's all perl.

    --
    જલધર

Re: Remote Administration using Apache mod_perl
by DrHyde (Prior) on Sep 05, 2003 at 08:43 UTC
    No, you really really REALLY don't want to do this with CGIs, it's a terrible idea.

    If you want a solution like ssh which needs to run through an http proxy then the suggestion of just putting an ssh server on a webby port probably won't help, because the proxy will try to parse ssh and get horribly confused.

    Instead, you need to wrap the ssh protocol in http. You want to use httptunnel, which lets you wrap *any* protocol in http. No need to use https of course, because while the wrapper might be plain-text, the ssh packets encapsulated therein are still nicely opaque.

    httptunnel can be downloaded from here.

Re: Remote Administration using Apache mod_perl
by tachyon (Chancellor) on Sep 05, 2003 at 02:34 UTC

    This is about as basic as you can get. You get a textbox to type commands into and a run button. Output goes to browser. Probably needs a little work on the security side ;-)

    The practical problem you face is that Apache will be running as user nobody or apache (ie not you) so you will be limited in what you can do. There are of course solutions to this problem.

    #!/usr/bin/perl $|++; use CGI qw( :standard ); use CGI::Carp qw( fatalsToBrowser ); my $command = param('command'); print header, start_form({ -method=>'get' }), textfield({-size=>75,-na +me=>'command'}), submit('Run'), end_form; if ($command) { open( CMD, "$command 2>&1|" ) or die "$!: running command: '$command +'"; print "<pre>"; print escapeHTML($_,1) while<CMD>; print "</pre>\n", end_html; close CMD; }

    cheers

    tachyon

    s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print

Re: Remote Administration using Apache mod_perl
by drone (Monk) on Sep 05, 2003 at 10:09 UTC
    Most good proxies support the CONNECT method so you can just fire up your sshd and use some program that can use the proxy to connect outside. ssh can use the ProxyCommand option to set a program that will connect through the proxy. You can write your own perl program that will act as a relay or you could find one on the search engines. Alternatively if you use windows on the client side you can use putty, a nice ssh terminal that has beautiful support for different kinds of proxies. I've used it and it works very nice. Some proxies do not allow to CONNECT to any port other than 80 or 443 so you would have to start sshd on one of these ports.
Re: Remote Administration using Apache mod_perl
by Roger (Parson) on Sep 05, 2003 at 10:23 UTC
    Are you running linux based or Windows based system on your computer? If it's a linux based system, you could use a free package called the 'webmin', from www.webmin.com, which can be configured to run in both the HTTP and HTTPS modes.

    If you are running windows based system, you could have a look at the same 'webmin' package compiled for 'cygwin'.

    The windows based system is certainly less secure than the linux based system.
Re: Remote Administration using Apache mod_perl
by johndageek (Hermit) on Sep 05, 2003 at 15:49 UTC
    Which direction are you going?

    From school to your computer at home?
    Go for it in any way you wish, assuming you are willing to risk it.

    From outside INTO school (an obviously protected zone).
    1) read your handbook, check the rules - you may forfeit more than you know by experimenting.
    2) as otherwise advised - check with IT (not a buddy in that area, but the SCHOOL security employee)

    Sometimes it is easier to ask for forgiveness than to ask permission.

    Forgiveness is not guaranteed

    dageek

      ...neither is permission. hence why one would ask for and expect neither...
Re: Remote Administration using Apache mod_perl
by CountZero (Bishop) on Sep 05, 2003 at 13:20 UTC

    Well, the proxy (and probably some firewalls too) are there for a reason. Could it be that they wish to avoid remote access to your or any other computer on their network?

    I would suggest you speak to the head of IT, explain your problem and ask for an *approved* solution.

    CountZero

    "If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law

A reply falls below the community's threshold of quality. You may see it by logging in.