use strict; use Net::SSH::Perl; my @key = ('identity_files', '/usr/home/username/.ssh/identity'); my $ssh = Net::SSH::Perl->new("host", @key); my $auth = Net::SSH::Perl::Auth->new('RSA', $ssh); print "Valid auth" if $auth->authenticate; my ($out, $err, $exit) = $ssh->cmd("uname -a"); print "$out\n";