in reply to Net::SSH2::Cisco not working on Cisco XR

You have the right idea checking dump files. I've had issues with XR also since the prompt is different. That's the main cause of "issues" - the script not finding the prompt. Note I've seen this with Net::Telnet::Cisco too, so it may not be a protocol thing, just simply not matching the prompt.

I see you've tried a custom prompt. I've had success with this in the past:

'/(?m:^(?:[\w.\/]+\:)?[\w.-]+\s?(?:\(config[^\)]*\))?\s?[\$#>]\s?(?:\( +enable\))?\s*$)/'

Replies are listed 'Best First'.
Re^2: Net::SSH2::Cisco not working on Cisco XR
by Xane (Initiate) on Mar 02, 2016 at 16:26 UTC
    Hi VinsWorldcom, Im still being timed out:
    command timed-out at ./ssh.pl line 25


    The regex i use in the prompt is the same as i use in my other scripts which uses Net::Telnet::Cisco. And these works on the XR devices which uses Telnet.


    When i used your prompt i still got the same in the dumps, unfortunately

      So if I understand correctly:

      • Net::Telnet::Cisco - IOS - your prompt - WORKS!
      • Net::SSH2::Cisco- IOS - your prompt - WORKS!
      • Net::Telnet::Cisco - XR - your prompt - WORKS!
      • Net::SSH2::Cisco - XR - your prompt - NOT WORKS :-(

      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.

        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; }
        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