Hello, I'm trying to write some code capable of authenticating with a private key on windows. I generate my key with no passphrase:
c:\var\client>ssh-keygen Generating public/private rsa key pair. Enter file in which to save the key (/home/user/.ssh/id_rsa): client_k +ey Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in client_key. Your public key has been saved in client_key.pub. The key fingerprint is: SHA256:eBU07eoloUWInreyZ2WkYMvBAhISc2OIsiE1gp+iS4E user@localhost The key's randomart image is: +---[RSA 3072]----+ |O=* . o+. | |X=.o . . .o. | |+= o o . ... | |E.o . B...+ . | |... +.=S* o | |.. +.+ = . | |.. o + o | |. . o . | | o | +----[SHA256]-----+
The key can be used successfully to authenticate:
c:\var\client>ssh -i client_key localhost Last login: Thu Aug 22 16:34:22 2019 $
My perl code is very simple at the moment:
use Net::SSH::Perl; my $server='localhost'; my %params = ( "protocol" => '2', "use_pty" => 0, "options" => ["stricthostkeychecking no"], "identity_files" => ["client_key"], "debug" => 1, ); $ssh = Net::SSH::Perl->new($server, %params); $ssh->login();
But executing it returns Wrong key type.
c:\var\client>perl test.pl localhost: Reading configuration data C:\Users\user\.ssh\config localhost: Reading configuration data C:\windows\ssh_config localhost: Connecting to localhost, port 22. localhost: Remote version string: SSH-2.0-OpenSSH_8.0 localhost: Remote protocol version 2.0, remote software version OpenSS +H_8.0 localhost: Net::SSH::Perl Version 2.14, protocol version 2.0. localhost: No compat match: OpenSSH_8.0. localhost: Connection established. localhost: Sent key-exchange init (KEXINIT), waiting for response. localhost: Using curve25519-sha256@libssh.org for key exchange localhost: Host key algorithm: ssh-ed25519 localhost: Algorithms, c->s: chacha20-poly1305@openssh.com <implicit> +none localhost: Algorithms, s->c: chacha20-poly1305@openssh.com <implicit> +none localhost: Generating ephemeral key pair. localhost: Entering Curve 25519 Key Exchange. localhost: Sent client public key, waiting for reply. localhost: Received host key, type 'ssh-ed25519'. localhost: Host 'localhost' is known and matches the host key. localhost: Verifying server signature. localhost: Send NEWKEYS. localhost: Waiting for NEWKEYS message. localhost: Enabling encryption/MAC/compression. localhost: Sending request for user-authentication service. localhost: SSH2_MSG_EXT_INFO received localhost: SSH Extension activated: server-sig-algs=ssh-ed25519,ssh-rs +a,rsa-sha2-256,rsa-sha2-512,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2-ni +stp384,ecdsa-sha2-nistp521 localhost: Service accepted: ssh-userauth. localhost: Trying empty user-authentication request. 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.
I've tried generating DSA type keys and the error is the same. Googling it is not helping either.

Any help appreciated!

Regards.


In reply to net::ssh::perl Wrong key type by jpsaraiva

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.