Invoking an SSH client by clicking a URL Link

C

cyrusgreats

Doe anyone know how to invoke an SSH client by clicking a URL Link.
I'm working on web page and wrote some perl cgi and I need to invoke
an ssh to send command to ssh server or client!
Thanks in advance..
 
C

cyrusgreats

Quoth (e-mail address removed):


Do you want the ssh command to be invoked on the web server or the
client?

If the latter, then this needs to be a function of the browser you are
using: some browsers (Firefox and IE, certainly) allow you to set up
arbitrary handlers for given URL schemes, but this would need to be done
on each machine your site was viewed from.

If the former, then you just need a link to a CGI (or something else
server-side) that uses one of the many SSH modules on CPAN to do what
you want. Be sure to arrange for the request to be a POST, rather than a
GET, since this is not an idempotent action.

Ben


Thanks Ben what I'm looking for is, say from page user can click on a
link in which it sends a command to Linux shell server something like
below perhaps!

<A HREF="ssh://ssh_cmd.cgi">Get directory list></A>

or perhaps
<form name=myssh method=post action="ssh_cmd.cgi">
 
J

Jens Thoms Toerring

Thanks Ben what I'm looking for is, say from page user can click on a
link in which it sends a command to Linux shell server something like
below perhaps!
<A HREF="ssh://ssh_cmd.cgi">Get directory list></A>

This can only work if the clients browser knows what to do,
i.e. the browser would have to have an idea what to do with
the 'ssh' protocol and then the handler for this protocol
had to know what to do with the rest of the URL. That would
reduce the usefulness to the small number of clents that
have the handler you would need installed, which may re-
strict it to your private computer.
or perhaps
<form name=myssh method=post action="ssh_cmd.cgi">

Now, that has per se nothing to do with ssh. It just will
result in a CGI script on the web server being invoked.
In that CGI script you could, of course, use ssh to get
some data from a third machine (or execute some command
on that third machine).

It might be better if you would explaing in more detail what
exactly you're planing to do instead of asking for a method
for doing something (ssh to somewhere). Then it would be
simpler to tell what's going to work and what not and, per-
haps, to come up with alternatives.

Regards, Jens
 
S

smallpond

Thanks Ben what I'm looking for is, say from page user can click on a
link in which it sends a command to Linux shell server

You didn't answer Ben's question. What is "it" in the above sentence.
Your possible choices are:
1) the browser on the client PC
2) the perl cgi on the web server

A page or a link can't send anything since they are just data, not
programs.
 
C

cyrusgreats

You didn't answer Ben's question.  What is "it" in the above sentence.
Your possible choices are:
 1) the browser on the client PC
 2) the perl cgi on the web server

A page or a link can't send anything since they are just data, not
programs.

Ok here the scenario:

1. user launch ie from windows say to automation webpage
2. There some options/links on automation page for example - by
clicking on a link, webpagee executes or send a command or run script
on remote linux server
3. the result of the above commands are printed into wepage

I've already wrote the page and need invoke ssh from webpage to send
command to remote linux server, hope I answered all your questions
 
J

Jens Thoms Toerring

Ok here the scenario:
1. user launch ie from windows say to automation webpage
2. There some options/links on automation page for example - by
clicking on a link, webpagee executes or send a command or run script
on remote linux server

Is it a remote machine that the web server has access to (via ssh)
or is it some random machine the client with the browser has
permissions to access only? The later variant would be a lot
more difficult and would open up a whole can of worms security-
wise...
3. the result of the above commands are printed into wepage
I've already wrote the page and need invoke ssh from webpage to send
command to remote linux server, hope I answered all your questions

Assuming that the web server has the necessary permissions to
access the remote machine where the command is to be executed
using a CGI script (invoked via a POST request from the browser)
is the way to go. In that CGI script you could use e.g. the
Net::SSH::perl module (that's the first one I found when sea-
rching on CPAN, but there might be a range of others...) to
execute the command, read the output, and put that output
(wrapped in some HTML) into the page (simply by writing it to
stdout) that then gets send back to the browser from which the
request was send.
Regards, Jens
 
T

Tad J McClellan

Ok here the scenario:

1. user launch ie from windows say to automation webpage
2. There some options/links on automation page for example - by
clicking on a link, webpagee executes or send a command or run script
on remote linux server
3. the result of the above commands are printed into wepage

I've already wrote the page and need invoke ssh from webpage to send
command to remote linux server, hope I answered all your questions


Is there an answer to Ben's and smallpond's question in there somewhere?

Do you want to do ssh from a browser or do you what to do ssh from a server?
 
C

cyrusgreats

Is there an answer to Ben's and smallpond's question in there somewhere?

Do you want to do ssh from a browser or do you what to do ssh from a server?

I want to send some commands to be executed using ssh from browser (in
this case windows) to server (linux).
regards, ssh authentication I've already took care of that part means
any client ssh to server without password.
 
J

Jens Thoms Toerring

I want to send some commands to be executed using ssh from browser (in
this case windows) to server (linux).
regards, ssh authentication I've already took care of that part means
any client ssh to server without password.

The browser by itself does not send commands. The browser can only
send requests to a web server or (if the browser allows it) invoke
some external programs for dealing with certain URLs the browser
doesn't know how to handle by itself (ssh is one of them).

Let's look again at the two scenarios:

a) The browser sends a (POST) request to the web server that makes
the web server execute a CGI script written in Perl. Within that
script you can ssh to any third machine the web server has access
to to your hearts desires. That way you could easily execute a
command on the third machine, read in the what it returns and
assemble a web page that then gets send back to the browser that
initiated the request. I already tried to give you some hints on
how to deal with that in a previous post.

b) On the same machine where the browser is running you have bound
a certain application (perhaps written in Perl) to a certain
protocol (ssh seems to be what you want). This requires that
this application is installed on the the machine the browser is
running on and that the browser is set up to invoke this appli-
cation when being asked to deal with the ssh protocol. That's
like when you click on an email address and then your favorite
email program pops up: the browser is set up to start the email
program whenever you click on a link that starts with 'mailto:'.

You still have not given any indication of what you're up to.
And just talking about 'ssh' won't make it any clearer.

Should you really have set up a Linux box to allow logins via ssh
without a password from everywhere on the internet then I can only
strongly recommend that you take it off tne net *NOW* or in a few
minutes it will be pwnded (or it already is).

Regards, Jens
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top