my $ssh_debug = 0; # verbose logging: 0-3
...
my $session_log_name = "ssh_$host.log";
open( my $session_log_fh, ">", $session_log_name )
or die "Failed to create logfile $session_log_name: $!";
binmode( $session_log_fh, ":unix" ); # unbuffer log file
...
$ssh_session{$host} = Net::OpenSSH->new(
# host
$host,
# automatically add new host keys to the user known hosts files
# enable verbosity, if enabled
master_opts => ($ssh_debug)
? [ -o => "StrictHostKeyChecking=no", "-" . "v" x $ssh_debug ]
: [ -o => "StrictHostKeyChecking=no" ],
# authentication
user => $username,
password => $password,
# logging
master_stderr_fh => $session_log_fh,
# connection parameters
timeout => $loginTO,
port => $ssh_port,
async => 1
);
}
####
elsif ( $ssh->error ) {
# handle connection error
my $lasterr = File::ReadBackwards->new("ssh_$host.log")->readline;
# ... something that outputs or logs the error message
}
####
Not a GLOB reference at /usr/local/share/perl/5.14.2/Net/OpenSSH.pm line 614.
612 sub _check_is_system_fh {
613 my ($name, $fh) = @_;
614 my $fn = fileno(defined $fh ? $fh : $name);
615 defined $fn and $fn >= 0 and return;
616 croak "child process $name is not a real system file handle";
617 }