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_key
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]-----+
####
c:\var\client>ssh -i client_key localhost
Last login: Thu Aug 22 16:34:22 2019
$
####
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();
####
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 OpenSSH_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 none
localhost: Algorithms, s->c: chacha20-poly1305@openssh.com 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-rsa,rsa-sha2-256,rsa-sha2-512,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521
localhost: Service accepted: ssh-userauth.
localhost: Trying empty user-authentication request.
localhost: Authentication methods that can continue: publickey,password,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/PublicKey.pm line 83.