SSH Key-Pair Authentication on Debian

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 and work it like follows.
# create key pair
jessie@dlp:~$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/jessie/.ssh/id_rsa):   # Enter
Enter passphrase (empty for no passphrase):   # set passphrase (set no passphrase to Enter with empty)
Enter same passphrase again:
Your identification has been saved in /home/jessie/.ssh/id_rsa.
Your public key has been saved in /home/jessie/.ssh/id_rsa.pub.
The key fingerprint is:
30:ee:f0:47:38:9d:8a:24:5e:01:c8:13:df:15:40:b4 jessie@dlp
The key's randomart image is:

jessie@dlp:~$ mv ~/.ssh/id_rsa.pub ~/.ssh/authorized_keys
jessie@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 keys authentication.
debian@www:~$ mkdir ~/.ssh
debian@www:~$ chmod 700 ~/.ssh
# copy the secret key to local ssh directory
debian@www:~$ scp jessie@10.0.0.30:/home/jessie/.ssh/id_rsa ~/.ssh/
jessie@10.0.0.30's password:
id_rsa
debian@www:~$ ssh jessie@10.0.0.30
Enter passphrase for key '/home/jessie/.ssh/id_rsa':   # passphrase
Last login: Wed April 24 21:37:19 2014 from www.srv.world
jessie@dlp:~$   # logined
[3] If you set "PasswordAuthentication no", it's more secure.
root@dlp:~# vi /etc/ssh/sshd_config
# line 52: turn to "no"
PasswordAuthentication no
root@dlp:~# systemctl restart ssh
DANS Media
Paham Ilmu, Kesehatan, dan Pengetahuan, tertarik dengan Financial Technology, mengajak banyak orang agar paham akan Ilmu dan Pengetahuan

Post a Comment

© DANS Media. All rights reserved. Distributed by DANS Media