Bootstrap FreeKB - Perl (Scripting) - Resolve "Wrong key type"
Perl (Scripting) - Resolve "Wrong key type"

Updated:   |  Perl (Scripting) articles

Let's say you are running one of your Perl scripts and something like this is being returned.

Wrong key type at /usr/local/bin/perl5.38.2/lib/site_perl/5.38.2/x86_64-linux/Net/SSH/Perl/Auth/PublicKey.pm line 123.

 

I first happened upon this when attempting to make an SSH connection using Net::SSH::Perl. Check out my articles Getting Started with Net::SSH::Perl and Public key authentication with Net::SSH::Perl.

To isolate the issue I set parameter debug => 'true'.

#!/usr/bin/perl
use strict;
use warnings;
use Net::SSH::Perl;

my %ssh_params = ( debug => 'true');
my $ssh = Net::SSH::Perl->new('server1.example.com', %ssh_params);
$ssh->login('john.doe', 'itsasecret');

 

And just before the "Wrong key key" stderr I saw that an id_ed25519 private key was being offerred.

Trying pubkey authentication with key file '/home/john.doe/.ssh/id_ed25519'
Wrong key type at /usr/local/bin/perl5.38.2/lib/site_perl/5.38.2/x86_64-linux/Net/SSH/Perl/Auth/PublicKey.pm line 81.

 

I didn't need my Perl script to use the id_ed25519 private key so I added the identity_files parameter pointing to an RSA private key, and the error was no longer returned.

my @private_keys = ("/home/john.doe/.ssh/id_rsa");
my %ssh_params = (
         debug => 'true',
         identity_files => \@private_keys
         );

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter f5253f in the box below so that we can be sure you are a human.