Beefy Boxes and Bandwidth Generously Provided by pair Networks Frank
There's more than one way to do things
 
PerlMonks  

Multi-hops with Net::OpenSSH

by silent11 (Vicar)
on May 29, 2009 at 17:55 UTC ( #766904=perlquestion: print w/ replies, xml ) Need Help??
silent11 has asked for the wisdom of the Perl Monks concerning the following question:

I'm sure my question is less about the module, Net::OpenSSH, and more about SSH in general.

I have a script, ScriptA, that SSH's into a machine and executes ScriptB, which also SSH's into a machine to do some work.

ScriptA must call ScriptB, as ScriptA is a sort of workflow framework that our group runs scripts out of.

My issue is when ScriptA SSH's into the machine containing ScriptB and attempts to execute it, I get this error:

Error: could not connect pty as controlling terminal!

Is there a limit to the number of times a script can SSH out , calling other scripts that SSH? Or do I need to override some setting, or pass an option to Net::OpenSSH to allow this?

TIA

Comment on Multi-hops with Net::OpenSSH
Download Code
Re: Multi-hops with Net::OpenSSH
by jpavel (Sexton) on May 29, 2009 at 19:27 UTC
    If I recall correctly, that's a feature of sshd. You can override it by issuing '-t' in your ssh command. e.g., "ssh -t <user>@<host".
      Most Net::OpenSSH commands accept an tty => 1 option exactly just for doing that.

      For instance:

      $ssh->system({tty => 1}, ssh => $hostB, $commandB);
        Hi salva,

        Do I include this this on ScriptA or ScriptB?

        ScriptA ssh's to $host1 and executes ScriptB which ssh's to $host2.

        I tried adding it to ScriptB but get the following error from Net::OpenSSH::new() (which is where my error is coming from)
        Invalid or bad combination of option ('tty')

        Thanks!
Re: Multi-hops with Net::OpenSSH
by Khen1950fx (Canon) on May 29, 2009 at 19:43 UTC
    I think that you should look at SSH::Batch. It might do the job better, and its built on top of Net::OpenSSH by salva. It'll also work on Windows.

    update: fixed typo

Re: Multi-hops with Net::OpenSSH
by ig (Vicar) on May 29, 2009 at 20:53 UTC

    I suspect the error comes from IO::Pty when it attempts to allocate a pseudo terminal. The '-t' option will force allocation of a pseudo terminal, but this may not make any difference for you as your application appears to already be attempting to do so, and failing.

    Net::OpenSSH uses IO::Pty to allocate a pseudo terminal and this, in turn, uses IO::Tty. The latter is documented to be system dependent. You might check the IO::Tty documentation to ensure the system you are on is listed as known working. In particular, if you are on Windows it says you must be using Cygwin. On the other hand, it says the list is out of date.

    A pseudo terminal will be allocated if you are using password authentication. If you are using password authentication, even if you can get pseudo terminals to work, you might be better off to heed the warning in the Net::OpenSSH documentation:

    Note that using password authentication in automated scripts is a very bad idea. When possible, you should use public key authentication instead.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://766904]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (7)
As of 2014-04-19 20:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (483 votes), past polls