In the following small script, I can not get $ssh->cmd executed successfully. $out and $err are all empty.

At the end of the debug log, it says: "
Authentication methods that can continue: password,publickey.
Next method to try is password.
Trying password authentication.
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
channel 1: new client-session
Requesting channel_open for channel 1.
Channel open failure: 1: reason 2:"
What can possibly cause the error “Channel open failure: 1: reason 2”? Where should I look into?

==== my simple script:

use Net::SSH::Perl;
use Net::SSH::Perl::Cipher;
my $hostname = "****";
my $username = "****";
my $passwd = "****";
my $ssh = Net::SSH::Perl->new($hostname, port => 22, interactive=> 0, debug => 1, protocol => 2);
$ssh->login($username, $passwd);
my $cmd = "ls –l ";
my($out,$err) = $ssh->cmd($cmd);
print "the output is $out\n";


In reply to Net::SSH::Perl question by 2007fld

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.