sub ops_do_ssh_shell { my ($cmd) = @_; my $ssh; my $key_path = defined $cmd->{key} ? $cmd->{key} : $ENV{HOME} . '/.ssh/id_rsa'; if ( ops_cmd_status($cmd) ) { $ssh = Net::OpenSSH->new($cmd->{host}, user => $cmd->{user}, key_path => $key_path); if ( $ssh->error ) { $cmd->{status} = 'failure'; ($cmd->{ssh_retcode}, $cmd->{ssh_retmsg}) = (0 + $ssh->error, '' . $ssh->error); } } if ( ops_cmd_status($cmd) ) { ($cmd->{output}, $cmd->{std_err}) = $ssh->capture2($cmd->{command}); $cmd->{cmd_ret_code} = 0 + $ssh->error; if ( $ssh->error ) { $cmd->{status} = 'failure'; $cmd->{cmd_ret_msg} = '' . $ssh->error; } chomp $cmd->{output}; chomp $cmd->{std_err}; } return $cmd; }