#!/usr/bin/perl -w use Net::SSH::Perl; use strict; my (%params, $ssherr, $sshexit); $params{'protocol'} = '2'; $params{'port'} = '22'; $params{'debug'} = 'true'; $params{'interactive'} = 'true'; $params{'compression'} = 'false'; $params{'identity_files'} = [$ENV{HOME}."/.ssh/id_rsa"]; $params{'options'} = ["RSAAuthentication yes", "PasswordAuthentication no", "ConnectTimeout 10", "BatchMode no", "FallBackToRsh no", "RhostsAuthentication no", "RhostsRSAAuthentication no", "KeepAlive yes"]; my $sshconn = Net::SSH::Perl->new("secsscsr01", %params); $sshconn->login('user', 'password'); my ($out1, $err1, $exit2) = $sshconn->cmd("ls -l"); if ($out1){print "Output:\n$_\n\n";} if ($err1){print "Error:\n$_\n\n";} print "Exit Code:\n$exit2\n\n";