View raw

1 #!/usr/bin/env perl 2 3 use v5.32.1; 4 use strict; 5 use warnings; 6 7 use FindBin; 8 use lib "${FindBin::Bin}/lib"; 9 use Test2::V0; 10 use FAPG::TestSupport qw(@HOSTS); 11 use Net::SSH::Perl; 12 13 foreach my $h (@HOSTS) { 14 my ( $out, $err, $exit ); 15 my $timeout = 5; 16 17 my $ok = eval { 18 local $SIG{ALRM} 19 = sub { die "SSH timeout after $timeout seconds.\n" }; 20 alarm $timeout; 21 22 my $ssh = Net::SSH::Perl->new( $h->{hostname} ); 23 $ssh->login( $h->{user}, $h->{password} ); 24 ( $out, $err, $exit ) = $ssh->cmd('true'); 25 26 1; 27 }; 28 29 alarm 0; 30 31 ok $ok, "host $h->{hostname} can be reached via ssh"; 32 diag $@ if $@; 33 34 } 35 36 done_testing(); 37