check if ssh connection works

This commit is contained in:
Christoph Klaffl 2019-02-20 18:06:04 +01:00
parent 234cc61e3a
commit e014fd7942
No known key found for this signature in database
GPG Key ID: FC1C525C2A47CC28
1 changed files with 7 additions and 0 deletions

View File

@ -1247,6 +1247,13 @@ sub getssh {
$socket = "/tmp/syncoid-$remoteuser-$rhost-" . time();
open FH, "$sshcmd -M -S $socket -o ControlPersist=1m $args{'sshport'} $rhost exit |";
close FH;
system("$sshcmd -S $socket $rhost echo -n") == 0 or do {
my $code = $? >> 8;
warn "CRITICAL ERROR: ssh connection echo test failed for $rhost with exit code $code";
exit(2);
};
$rhost = "-S $socket $rhost";
} else {
my $localuid = $<;