I am trying to get the version information off of a cisco sg300 smart switch. I have decided to use the module Net::SSH2::Cisco which I have used in the past for a cisco phone server. When running the following script

#!/usr/bin/perl use warnings; use strict; use Net::SSH2::Cisco; my $host = "<my_host>"; my $user = "<my_user>"; my $password = "<my_password>"; my $session = Net::SSH2::Cisco->new(host => $host); $session->login(username => $user, password => $password); my @version = $session->cmd("show version"); print @version; $session->close;

I get the following error

Net::SSH2 error -18:LIBSSH2_ERROR_PUBLICKEY_UNRECOGNIZED Authentication failed (username/password) authentication failed for user - `cisco' at ./switch.pl line 12

Not really sure what the issue here is. I can ssh into the switch no problem from the command line.

Thanks in advanced

** Update **

I think I have isolated the issue but now need to figure out how to implement it. The issue seems to be related to the expected prompt for the username/login. The switch expects "User Name:" as the prompt. I've switched to using the module Net::Appliance::Session which appears to have a way to allow custom prompts, just a matter of figuring it out now. Help always appreciated.


In reply to Issue with ssh to a cisco smart switch by edimusrex

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.