Hi Perl Monk, this is my very first post here, so hi everybody!
I am currently writing a script that is connecting to all our Linux servers and gets information such as Network configuration, OS type, architecture, running services and so on...
We are getting the server IP from a database where ALL our equipment is listed - which includes appliances/switches/router, therefore without the correct credentials.
Note that before trying to authenticate against any equipment, I am checking if the remote server has port 22 opened.
The problem I am seeing is that when the code (CF below) is failing to authenticate against an equipment, the scripts exits.
I have surrounded the connection to the server with an "eval" statement which I thought would have prevented the script from exiting and instead, display the error but it is just failing with the following error message:
Received disconnect message: Too many authentication failures for abc
at /usr/local/lib/perl5/site_perl/5.10.0/Net/SSH/Perl/AuthMgr.pm line
+ 143
I have tried and used Error.pm and surrounded the connection statement with a "try/catch/finally" statement but the result was the same ...
Here is the code I am running to connect to the remote SSH server:
sub connectToServer{
my $username = "abc";
my $serverName = $_[0];
chomp($serverName);
my $ssh;
eval { $ssh = Net::SSH::Perl->new($serverName)
or die "Unable to connect";
};
if ($@){
warn "Connection failed: $@\n";
return "Problem to connect";
}else{
$ssh->login($username);
return $ssh;
}
}
Does anyone has any experience with this Perl module (Net::SSH::Perl) and could give me some help with this issue?
Thanks a lot in advance :)
Cheers
Gael
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.