Folks-

Given machine A, B, and C...

I'm trying to login from A to B and remotely execute an interactive command on C.

A is running a perl script that uses Net::SSH:Perl to machine B. This works fine for both SSH1 and SSH2.

Then A tries to run ssh -t -l $usr2 $machineC icommand" from machine B

This will work for SSH1, but will fail for SSH2 failing with:
ERR: Pseudo-terminal will not be allocated because stdin is not a terminal.

Machine A has been both a Sun and MacOS, and I see the same failure. My research indicates that Net::SSH::Perl is failing to setup the tty on machine B. Although I'm running an older version of Net::SSH::Perl, I don't see any code in the new version to fix this either.

Test code is attached - using "uname-a" instead of an interactive command, and ssh -t to force the error.

Any thoughts on how I can get this to work with SSH2?

Thanks

-Craig

UPDATE: I was able to modify SSH2.pm to fix this problem. A bug report has been submitted along with my code hacks to SSH2.pm that make it work.

use strict; use warnings; use Net::SSH::Perl; use Net::SSH::Perl::Constants qw( :msg ); my $host1='machineB'; my $usr1='usrB'; my $pass1='passwdB'; my $host2 = 'machineC'; my $usr2 = 'usrC'; my $cmd = "/opt/exp/bin/ssh -t -l $usr2 $host2 uname -a"; my $debug=0; my $ssh1 = Net::SSH::Perl->new($host1, use_pty=>1, protocol=>1, interactive=>1, debug=>$debug) || die "Cannot conntact target machine, exiting..."; $ssh1->login($usr1, $pass1) || die "Bad login, exiting..."; print STDERR "\n\nUsing SSH1 Protocol\n"; my ($out, $err, $exit) = $ssh1->cmd($cmd); print STDERR "exit=$exit\n"; print STDERR "OUT: $out\n" if $out; print STDERR "ERR: $err\n" if $err; # Using SSH2... # Adding use_pty=>1 does not work when using SSH2. See: # http://www.derkeiler.com/Newsgroups/comp.security.ssh/2003-05/0097.h +tml my $ssh2 = Net::SSH::Perl->new($host1, protocol=>2, use_pty=>1, interactive=>1, debug=>$debug) || die "Cannot conntact target machine, exiting..."; $ssh2->login($usr1, $pass1, 0) || die "Bad login, exiting..."; print STDERR "\n\nUsing SSH2 Protocol\n"; ($out, $err, $exit) = $ssh2->cmd($cmd); print STDERR "exit=$exit\n"; print STDERR "OUT: $out\n" if $out; print STDERR "ERR: $err\n" if $err;

In reply to Net::SSH::Perl pty problem with SSH2? SOLVED by cmv

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.