Ubuntu 17.04
Sponsored Link

SSH Key-Pair Authentication2017/04/19

 
Configure SSH server to login with Key-Pair Authentication. Create a private key for client and a public key for server.
[1] Create Key-Pair for each user, so login with a user you'd like to set Key-Pair Auth and work it like follows.
ubuntu@dlp:~$
ssh-keygen

Generating public/private rsa key pair.
Enter file in which to save the key (/home/ubuntu/.ssh/id_rsa):  
# Enter

Enter passphrase (empty for no passphrase):  
# set passphrase (if not set, Enter with empty)

Enter same passphrase again:
Your identification has been saved in /home/ubuntu/.ssh/id_rsa.
Your public key has been saved in /home/ubuntu/.ssh/id_rsa.pub.
The key fingerprint is:
30:ee:f0:47:38:9d:8a:24:5e:01:c8:13:df:15:40:b4 ubuntu@dlp
The key's randomart image is:

ubuntu@dlp:~$
mv ~/.ssh/id_rsa.pub ~/.ssh/authorized_keys

ubuntu@dlp:~$
chmod 600 ~/.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.
ubuntu@www:~$
mkdir ~/.ssh

ubuntu@www:~$
chmod 700 ~/.ssh
# copy the secret key to the local ssh directory

ubuntu@www:~$
scp ubuntu@10.0.0.30:/home/ubuntu/.ssh/id_rsa ~/.ssh/

ubuntu@10.0.0.30's password:
id_rsa
ubuntu@www:~$
ssh ubuntu@10.0.0.30

Enter passphrase for key '/home/ubuntu/.ssh/id_rsa':  
# passphrase

Last login: Wed April 18 21:37:19 2017 from www.srv.world
ubuntu@dlp:~$  
# just logined

[3] If you set "PasswordAuthentication no", it's more secure.
root@dlp:~#
vi /etc/ssh/sshd_config
# line 56: uncomment and turn to "no"

PasswordAuthentication
no
root@dlp:~#
systemctl restart ssh

SSH Key-Pair Authentication from Windows Client
 
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.
Matched Content