use strict; use warnings; use Net::SSH::Perl; use Net::SSH::Perl::Auth; use Net::SSH::Perl::Auth::RSA; use Net::SSH::Perl::Auth::PublicKey; use Net::SSH::Perl::Agent ; my @ids = ("/home/abc/.ssh/id_rsa"); my %params = ( 'protocol' => 2, 'interactive' => 1, 'identity_files' => \@ids, ); my $host = "server"; my $login = Net::SSH::Perl->new($host, %params)|| die "could not create ssh object for host"; my $auth = Net::SSH::Perl::Auth->new('PublicKey', $login) || die "could not create Auth object"; $auth->authenticate;