Perl Net :: SSH :: Any with key exchange
I need to be able to use Perl to detect the version of python running on remote servers that I have a key exchange with. To try and do this I have used Net::SSH::Any
but want to use key exchange instead of specifying the password in the script. I looked at an example cpan that specifies a password.
Below is a snippet of my Perl code that I am trying to determine if python 2.6 is installed on the remote server.
my $ssh = Net::SSH::Any->new( $curIP, 'root' );
my @out = $ssh->capture("python -V");
my $outSize = @out;
my $ver26 = 0;
for ( my $j = 0; $j < $outSize; $j++ ) {
if ( index( $out[$j], "2.6." ) != -1 ) {
$ver26 = 1;
}
}
When I run this it complains and says to specify the host:
required host parameter is missing from the line. /GenerateConfig.pl 162
I changed the code similar to how it is done in another post ( How can I FTP a file with an SSH key instead of a password in Perl? ), But it also fails:
my $ssh = Net::SSH::Any->new( $curIP, {'root'} );
my @out = $ssh->capture("python -V");
my $outSize = @out;
my $ver26 = 0;
for ( my $j = 0; $j < $outSize; $j++ ) {
if ( index( $out[$j], "2.6." ) != -1 ) {
$ver26 = 1;
}
}
Any thoughts on how I can do this, or an alternative to doing the same thing, would be greatly appreciated.
source to share
According to the documentation for Net :: SSH :: Any, you need to pass it a hostname and parameter pairs:
my $ssh = Net::SSH::Any->new($curIP, user => 'root');
source to share