in reply to Net::SSH::Perl question

FWIW - your script works fine on my system: CentOS 5.3, perl v5.10.0, Net::SSH::Perl 1.34 and open-ssh 4.3p2-29.

Reason 2 is SSH_OPEN_CONNECT_FAILED (see rfc4254). This is an error indication from the server back to the client. To find the cause of the failure you should investigate your ssh server. Maybe it is logging an error. Maybe you can run the server with debug option to get more information.

update: There is something odd about your debug output. On my system I get:

Login completed, opening dummy shell channel. channel 0: new [client-session] Requesting channel_open for channel 0. channel 0: open confirm rwindow 0 rmax 32768 Got channel open confirmation, requesting shell. Requesting service shell on channel 0. channel 1: new [client-session] Requesting channel_open for channel 1. Entering interactive session.

The messages Login completed, opening dummy shell channel. and Got channel open confirmation, requesting shell. are both produced by the login method of Net::SSH::Perl::SSH2.pm. I have checked the source code on CPAN and the latter message is in every version back to 1.24 released back in 2003. Yet your trace doesn't have this second message. Recent versions have added a third argument to the login method to prevent opening a shell, but you have not used the third argument so the latter message should be there. I don't see any other path that would avoid the production of the latter message.

This suggests that your version of Net::SSH::Perl is not as on CPAN. You may have a version modified by your distribution provider or you may have a corrupt version. You might try installing Net::SSH::Perl from CPAN and see what happens.

Replies are listed 'Best First'.
Re^2: Net::SSH::Perl question
by 2007fld (Acolyte) on Aug 04, 2009 at 19:05 UTC
    Thanks for the reply.

    Below is the trace again. It looks just like yours, except the last line with the error message. (I guess I missed something when I pasted my trace first time.)

    Do you think it is a connection issue, or perl module issue?

    Login completed, opening dummy shell channel.
    channel 0: new client-session
    Requesting channel_open for channel 0.
    channel 0: open confirm rwindow 131072 rmax 98304
    Got channel open confirmation, requesting shell.
    Requesting service shell on channel 0.
    channel 1: new client-session
    Requesting channel_open for channel 1.
    Entering interactive session.
    Channel open failure: 1: reason 2:

      OK, that looks normal, except for the channel open failure. This is an error indication from the SSH server you are connecting to. You should investigate the server for clues, including any logs it produces. You should find an explanation there.

      What ssh server are you connecting to and what operating system is it running on?

      If you don't need a pseudo terminal (pty) you might try added use_pty => 0 to your options to Net::SSH::Perl->new(). There is a comment in the source code that support for pty is experimental. Maybe it doesn't work with some servers. You don't need a pseudo terminal to run an ls command.