Sponsored Link

OpenSSH : SSH Key-Pair Authentication
Configure SSH server to login with Key-Pair Authentication. Create a private key for client and a public key for server to do it.
[1] Create Key-Pair for each user, so login with a common user on SSH Server Host and work like follows.
# create key-pair

ssh-keygen -t ecdsa

Generating public/private ecdsa key pair.
Enter file in which to save the key (/home/suse/.ssh/id_ecdsa):   # Enter or input changes if you want
Created directory '/home/suse/.ssh'.
Enter passphrase (empty for no passphrase):    # set passphrase (if set no passphrase, Enter with empty)
Enter same passphrase again:
Your identification has been saved in /home/suse/.ssh/id_ecdsa.
Your public key has been saved in /home/suse/.ssh/
The key fingerprint is:
SHA256:qO9MuPq5q1zP7KwRX+gahSBuDqP+1ucVFmIbpPIkDjk suse@dlp
The key's randomart image is:

ll ~/.ssh

total 8
-rw------- 1 suse users 314 Jan 14 17:21 id_ecdsa
-rw-r--r-- 1 suse users 170 Jan 14 17:21

mv ~/.ssh/ ~/.ssh/authorized_keys

[2] Transfer the secret key created on the Server to a Client, then it's possbile to login with Key-Pair authentication.
mkdir ~/.ssh

chmod 700 ~/.ssh
# copy the secret key to the local ssh directory

scp suse@ ~/.ssh/

suse@'s password:
ssh suse@

Enter passphrase for key '/home/suse/.ssh/id_ecdsa':    
# passphrase if you set

Last login: Tue May 7 19:16:49 2018 from
# just logined

[3] If you set like follows, it's more secure.
dlp:~ #
vi /etc/ssh/sshd_config
# line 63, 67: uncomment and change to [no]


dlp:~ #
systemctl restart sshd

SSH Key-Pair Authentication from Windows Client #1
It's the example to login to SSH server from Windows Client. It uses Putty on here.
Transfer a secret key to Windows Client first.
[4] Download [Puttygen.exe] from Putty Site and save it under the Putty directory. Next execute it and click [Load] button.
[5] Specify the secret key which you downloaded, then passphrase is required like follows, answer it.
[6] Click [Save private key] button to save it under a folder you like with any file name you like.
[7] Start Putty and open [Connection] - [SSH] - [Auth] on the left menu, then select the [private_key] which was just saved above.
[8] Back to the [Session] on the left menu and connect to the SSH server.
[9] The passphrase is required to login, then answer it. If it's correct, it's possible to login normally like follows.
SSH Key-Pair Authentication from Windows Client #2
[10] If your Windows is Windows 10 Version 1803 or later like here, OpenSSH Client has been implemented as a Windows feature, so it's possbile to authenticate with SSH Key-Pair without Putty and others. Transfer the secret key to your Windows 10 and put it uder the [(logon user home).ssh] folder like follows, then it's ready to use Key-Pair login.
Matched Content