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

Hi,

I'm trying to write a program in perl which runs ssh login to a unix box interactively from a web browser.

I can get the username from a textfield before ssh'ing to the box, but I don't know whether the authentication method is password or securid until I've connected to that box, at which stage I need the user input again to tell me their password/securid.

How can I get this without a textfield and submit button that posts back and reloads the page?

Hope this make sense! Thanks for any help.

js1.

Replies are listed 'Best First'.
Re: getting input without submit
by graff (Chancellor) on Nov 16, 2005 at 23:38 UTC
    I'm trying to write a program in perl which runs ssh login to a unix box interactively from a web browser.

    Sorry, but... Why do you want to do that? That is, what are you trying to accomplish, really? (What is the goal?)

    While you work on the answer to that question, think about this: supposing you could succeed in starting an interactive login on a unix box from a web browser. What would happen next? What goes to the browser if/when the login succeeds? What do you expect to happen to the login when the perl script on the webserver finishes writing stuff back to the browser?

    (Hint: a unix login implies an interactive shell, which sends a prompt to the user via its stdout, waits for a command line on its stdin (typically a tty device), and exits when it detects EOF on stdin or a write failure on stdout. You can do a login that simply executes a particular script or process, but this is non-interactive.)

    Depending on what you're actually trying to accomplish, there's probably a way to do it -- but if it involves an interactive login shell on the unix box, I don't think you'll be doing that via a browser.

      Thanks for your reply. I do take your points but let me try and explain a bit better what I'm trying to do.

      I have been coding something (in Perl) like Webmin which enables an Adminstrator to set up an apache instance by configuring it in a browser. So far, I've got it to create the apache config, and import this to CVS through a series of forms where the user is asked to fill in brief details e.g. ServerName, Listen, etc.

      The next step I want it to do is deploy the instance to the remote server where it's going to run.

      I could probably do this quite easily with Net::SSH or Expect.pm if it wasn't for the fact that we don't allow Root logons at work. A user must ssh to the remote box as themselves first, then su.

      The problem is there are a lot of boxes, and authentication is usually via SecurID (although sometimes it's password). That's where I need to go back to the user and get their password or passcode.

      I realise it would be a lot easier if I pulled the install to the box instead of pushing it out, but for convenience, I'd just like to come up with a way to push out the deployment so the apache config, cvs commit and deployment could all be done from one place.

      Thanks,

      js1.

Re: getting input without submit
by Errto (Vicar) on Nov 17, 2005 at 04:01 UTC
    You can use a full-fledged SSH client directly in a browser through applets. This might be a heck of a lot easier than trying to fake it through Perl/CGI, not to mention the issues raised by graff. Here's one that I've seen around.