Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re^2: net::ssh::perl Wrong key type

by jpsaraiva (Novice)
on Aug 23, 2019 at 08:48 UTC ( #11104883=note: print w/replies, xml ) Need Help??


in reply to Re: net::ssh::perl Wrong key type
in thread net::ssh::perl Wrong key type

Hi jcb,

Thank you for the pointer, unfortunatelly it does not work.

I've seen that on other modules like Net::SSH2, auth_publickey expects the path for both public and private keys.

It appears not to be the case with Net::SSH::Perl. Adding the public key does not change the outcome:

my %params = ( "protocol" => '2', "use_pty" => 0, "options" => ["stricthostkeychecking no"], "identity_files" => ["client_key","client_key.pub"], "debug" => 1, ); $ssh = Net::SSH::Perl->new($server, %params);# debug=>1, identity_file +s=>\@KEYFILE); $ssh->login();
localhost: Authentication methods that can continue: publickey,passwor +d,keyboard-interactive. localhost: Next method to try is publickey. localhost: Trying pubkey authentication with key file 'client_key' Wrong key type at C:/Strawberry/perl/site/lib/Net/SSH/Perl/Auth/Public +Key.pm line 83.

If I try having the public key in the first place it just fails and tries the next one:

localhost: Next method to try is publickey. localhost: Trying pubkey authentication with key file 'client_key.pub' Use of uninitialized value $object in substitution (s///) at C:/Strawb +erry/perl/site/lib/Net/SSH/Perl/Key.pm line 109. Use of uninitialized value $object in substitution (s///) at C:/Strawb +erry/perl/site/lib/Net/SSH/Perl/Key.pm line 109. localhost: Will not query passphrase for 'client_key.pub' in batch mod +e. Use of uninitialized value $object in substitution (s///) at C:/Strawb +erry/perl/site/lib/Net/SSH/Perl/Key.pm line 109. Use of uninitialized value $object in substitution (s///) at C:/Strawb +erry/perl/site/lib/Net/SSH/Perl/Key.pm line 109. localhost: Loading private key failed. localhost: Trying pubkey authentication with key file 'client_key' Wrong key type at C:/Strawberry/perl/site/lib/Net/SSH/Perl/Auth/Public +Key.pm line 83.

I'm going to try all the key formats I manage to generate to check if there any issue there, since I don't know what else might be causing the problem.

Regards.

Replies are listed 'Best First'.
Re^3: net::ssh::perl Wrong key type
by jpsaraiva (Novice) on Aug 23, 2019 at 11:40 UTC

    Found out a format that worked!

    ssh-keygen by default generates keys like:

    -----BEGIN OPENSSH PRIVATE KEY----- ...

    I tried other combinations until I found one that worked:

    $ openssl genrsa -out privatekey -----BEGIN RSA PRIVATE KEY----- ... $ chmod 600 privatekey $ ssh-keygen -y -f privatekey > publickey

    Running the script again, results in a successful login:

    localhost: Trying pubkey authentication with key file 'privatekey' localhost: Login completed, opening dummy shell channel. localhost: channel 0: new [client-session] localhost: Requesting channel_open for channel 0.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://11104883]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (9)
As of 2019-10-21 19:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?