in reply to Re^2: Net::SSH2::Cisco not working on Cisco XR
in thread Net::SSH2::Cisco not working on Cisco XR

So if I understand correctly:

There are some differences in Net::Telnet and Net::SSH2 that underly the Cisco flavor of these modules that I had to work around for the SSH2 case. Have you tried:

waitfor_clear => 1 # 1 is default, you use 0 binmode => 1 # 0 is default blocking => 1 # 0 is default Win32 only works with 0

I'd try each of the above with your new() call one at a time systematically eliminating them. From your OP, the dump seems to indicate the prompt is *not* seen on XR (you don't see "DEVICE" in the XR dump, you do in the IOS dump). The other thing to try is just using Net::SSH2 directly to eliminate if any of the bells and whistles I liberally "borrowed" from Net::Telnet / Net::Telnet::Cisco are causing issues with the way Net::SSH2 makes and maintains its connection.

Replies are listed 'Best First'.
Re^4: Net::SSH2::Cisco not working on Cisco XR
by Xane (Initiate) on Mar 04, 2016 at 09:30 UTC
    Hi,
    Yes, you understand correctly.

    I tried as you mentioned above, eliminating each of the constructors, but with no success.
    I have a Net::SSH2 script working, yes. But to save my self from rewriting all of my scripts i wanted to use Net::SSH2::Cisco
    foreach $up(@hosts) { chomp($up); my $user = "user"; # your account my $ssh2 = Net::SSH2->new(); $ssh2->debug(0); $ssh2->connect($up) or die "Unable to connect host $@ \n"; $ssh2->auth_password($user,$passwd); my $chan = $ssh2->channel(); $chan->exec('sh ver bri'); my $buflen = 3000; my $buf1 = '0' x $buflen; $chan->read($buf1, $buflen); print $up, $buf1; }

      You'll notice in Net::SSH2::Cisco login(), that the shell() method is used, not exec(). This is so multiple commands can be issue in an interactive fashion.

      Try your above Net::SSH2 script with shell() instead of exec() and see if it still works. That will help narrow down / eliminate anther possibility.

Re^4: Net::SSH2::Cisco not working on Cisco XR
by Xane (Initiate) on Mar 16, 2016 at 14:41 UTC
    Sorry for late reply.

    Ive tried with:
    my $channel = $ssh->channel();
    $channel->blocking(0);
    $channel->shell();

    But still the same. When trying this on regular IOS, it works fine. When trying on XR i get the same as when using Net::SSH2::Cisco

      So if I understand correctly, using Net::SSH2 alone with the shell() call fails as well. If that's the case, there's pretty much no hope for Net::SSH2::Cisco to work since that's what it does.

      I'm loathe to put an exec() option in there since the Net::SSH2 documentation says to use shell() for multiple commands, which is the purpose of Net::SSH2::Cisco.

      Last thing to try - I uploaded a new version 0.02 to CPAN. Download that one and try this:

      ....->new(...) $host->send_wakeup('noflush'); $host->login(...

      Essentially, you're just calling send_wakeup('noflush') after the constructor, before the login() call. It works with or without the send_wakeup() call for me with IOS; I don't have XR to test on.