Hello garcimo,
There are plenty of reasons that the script that I told you could fail. I will explain just the basic ones:
1) Are you sure that all the nodes (190) have ssh keys generated and the ssh-agent is added? If not follow this perfect tutorial from gitHub Generating a new SSH key and adding it to the ssh-agent.
2) Are you sure that the password that you provide is correct? I mean if you have special characters inside your password it could fail. You need to escape special characters e.g. \@, \$, \_ etc etc...make sure your password is correct.
3) Firewall, are you sure that you can ssh to all nodes?
Many other reasons I could add here but there is no point, I would suggest that first make sure that you can ssh to all nodes, all nodes have generated ssh-keys, the agents are added and all can communicate with the main node.
I put a small script that assumes that all the information is correct and checked and then it does the rest for you. It will ssh-copy-id for each node from main to the rest of the nodes and in case of either success or error it will print the output for you, so you can identify the node with the problem.
Keep in mind that this is a minimum sample of script, you should hash the output of each node so you can identify the problem easier, or maybe some nodes will fail some will pass etc...etc...
#!/usr/bin/perl
use Expect;
use strict;
use warnings;
use Data::Dumper;
my $path_to_file = "test.txt";
open my $handle, '<', $path_to_file
or die "Could not open file '".$path_to_file."': $!";
chomp(my @devices = <$handle>);
close $handle
or warn "Could not close '".$path_to_file."': $!";
# print Dumper \@devices;
my @params;
my $username = "user";
my $ssh_copy_id = "ssh-copy-id ".$username."\@";
my $password = "password";
# These is to bypass the
foreach my $device (@devices) {
# create an Expect object by spawning another process
my $command = join('', $ssh_copy_id, $device);
# print $command . "\n";
my $session = Expect->spawn($command)
or die "Error calling external program: $!";
my $output;
$session->expect(10,
[ qr/passphrase/i, sub { my $self = shift;
$self->send("$password\n");
exp_continue; }],
[ qr/my comments/i, sub { my $self = shift;
$output = $self->exp_before;
exp_continue; }],
);
print $output . "\n" if $output;
$session->soft_close;
}
In case that all of that is too much work for you and you decide that you want to proceed with simple password procedure (for my point of view you should not) there is an old question that I raised that I was testing multiple ways on doing that and even applying sudo commands see here Best module to execute administrator commands on external operating systems (Linux), similar with the ssh parrallel module Net::OpenSSH::Parallel with sudo commands.
In case that you come across other problems I would suggest raise another question, because this question is not related with other problems. :)
Hope this helps, BR.
Seeking for Perl wisdom...on the process of learning...not there...yet!
|