ssh -p 22 user@host
without password as I have set up the ssh key authentication.When I am using the module Net::OpenSSH::Parallel
####
0.488| [192.168.24.16] added (HASH(0x19e5f70))
0.488| [192.168.24.16] state set to done
0.488| selector(*) --> [192.168.24.16]
0.488| [192.168.24.16] action command queued
0.488| [192.168.24.16] state changed done --> ready
0.488| run: iterating...
0.488| run: hosts at connecting: 0
0.488| run: hosts at ready: 1
0.488| num workers: 1, maximum: 1
0.488| [192.168.24.16] at_ready
0.488| [192.168.24.16] at_ready, starting new action command
0.488| [192.168.24.16] host is not connected, connecting...
0.488| [192.168.24.16] _connect, starting SSH connection
Invalid or bad combination of options ('key_path') at parallel_ssh.pl line 41.
####
#!/usr/bin/perl
use strict;
use warnings;
use Data::Dumper;
use Net::OpenSSH::Parallel;
$Net::OpenSSH::Parallel::debug = -1;
my %hosts = ( 'localhost' => { host => "127.0.0.1",
user => "user",
port => "22",
psw => "psw",
key => "/home/user/.ssh/id_rsa", },
);
my $maximum_workers = scalar (keys %hosts);
my $maximum_connections = 2 * $maximum_workers;
my $maximum_reconnections = 0;
my %opts = ( workers => $maximum_workers,
connections => $maximum_connections,
reconnections => $maximum_reconnections
);
my $pssh = Net::OpenSSH::Parallel->new( %opts );
foreach my $label (keys %hosts) {
$pssh->add_host( #$hosts{$label},
$hosts{$label}{host},
user => $hosts{$label}{user},
port => $hosts{$label}{port},
password => $hosts{$label}{psw},
key_path => $hosts{$label}{key},
);
}
#print Dumper $pssh;
$pssh->push('*', command => 'ls');
$pssh->run;