$ssh2= Net::SSH2->new(); my $host = 'serveraddress'; my $port = 22; my $user = 'username'; $ssh2->connect($host, $port) or $ssh2->die_with_error; my $ppk_filepath = 'C:\Users\username\rsa-key-username'; print "$ppk_filepath exists!\n" if -e $ppk_filepath; $ssh2->auth_publickey($user, undef, $ppk_filepath, 'passphrase123' ) or $ssh2->die_with_error; #### use Net::SSH::Any; $Net::SSH::Any::debug = -1; my $host = 'serveraddress'; my $port = 22; my $user = 'username'; my $ppk_filepath = 'C:\Users\username\rsa-key-username'; $ssh2 = Net::SSH::Any->new($host, port => $port, user => $user, passphrase => 'passphrase123', key_path => $ppk_filepath, backends => 'Net_SSH2'); if ($ssh2->error) { die "Connection error: " . $ssh2->error; }