Invoking an SSH client by clicking a URL Link

Discussion in 'Perl Misc' started by cyrusgreats@gmail.com, Mar 25, 2009.

  1. Guest

    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..
     
    , Mar 25, 2009
    #1
    1. Advertising

  2. Guest

    On Mar 25, 11:23 am, Ben Morrow <> wrote:
    > Quoth :
    >
    > > 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!

    >
    > 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">
     
    , Mar 25, 2009
    #2
    1. Advertising

  3. wrote:
    > On Mar 25, 11:23 am, Ben Morrow <> wrote:
    > > Quoth :
    > >
    > > > 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!

    > >
    > > 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>


    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
    --
    \ Jens Thoms Toerring ___
    \__________________________ http://toerring.de
     
    Jens Thoms Toerring, Mar 25, 2009
    #3
  4. smallpond Guest

    On Mar 25, 3:58 pm, wrote:

    > 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.
     
    smallpond, Mar 25, 2009
    #4
  5. Guest

    On Mar 25, 2:15 pm, smallpond <> wrote:
    > On Mar 25, 3:58 pm, wrote:
    >
    > > 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.


    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
     
    , Mar 25, 2009
    #5
  6. wrote:
    > On Mar 25, 2:15 pm, smallpond <> wrote:
    > > On Mar 25, 3:58 pm, wrote:
    > >
    > > > 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.


    > 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
    --
    \ Jens Thoms Toerring ___
    \__________________________ http://toerring.de
     
    Jens Thoms Toerring, Mar 25, 2009
    #6
  7. <> wrote:
    > On Mar 25, 2:15 pm, smallpond <> wrote:
    >> On Mar 25, 3:58 pm, wrote:
    >>
    >> > 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.

    >
    > 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?


    --
    Tad McClellan
    email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"
     
    Tad J McClellan, Mar 25, 2009
    #7
  8. Guest

    On Mar 25, 3:23 pm, Tad J McClellan <> wrote:
    > <> wrote:
    > > On Mar 25, 2:15 pm, smallpond <> wrote:
    > >> On Mar 25, 3:58 pm, wrote:

    >
    > >> > 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.

    >
    > > 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?
    >
    > --
    > Tad McClellan
    > email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"


    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.
     
    , Mar 25, 2009
    #8
  9. wrote:
    > On Mar 25, 3:23 pm, Tad J McClellan <> wrote:
    > > <> wrote:
    > > > On Mar 25, 2:15 pm, smallpond <> wrote:
    > > >> On Mar 25, 3:58 pm, wrote:

    > >
    > > >> > 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.

    > >
    > > > 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?


    > 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
    --
    \ Jens Thoms Toerring ___
    \__________________________ http://toerring.de
     
    Jens Thoms Toerring, Mar 25, 2009
    #9
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. loial
    Replies:
    0
    Views:
    422
    loial
    Feb 3, 2009
  2. loial
    Replies:
    0
    Views:
    416
    loial
    Feb 10, 2009
  3. F. Da Costa
    Replies:
    2
    Views:
    96
    F. Da Costa
    Feb 6, 2004
  4. pavi
    Replies:
    0
    Views:
    1,357
  5. friday13
    Replies:
    3
    Views:
    209
    friday13
    Apr 28, 2007
Loading...

Share This Page