Membuat SSH Key Authentication Di Centos 7

Membuat SSH Key Authentication Di Centos 7

Membuat SSH Key AuthenticationMembuat SSH Key Authentication Di Centos 7. Terkadang ssh ke sebuah server selalu meminta password untuk bisa masuk pada root server. Namun dengan membuat SSH Key Authentication tidak perlu lagi memasukan password. Karena password sudah di store pada masing-masing server menggunakan enkripsi. Pada default SSH Key Authentication ini tidak secara otomatis ada.

SSH Key Auth Antar Server Linux

IP Server: 192.168.1.10 (Perangkat yang di remote)

IP Client: 192.168.1.20 (Perangkat yang meremote)

1. Buat dulu RSA Key pada Client (192.168.1.20)

ssh-keygen -t rsa

Lokasi RSA Key Tersimpan, Tekan enter

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

Tekan Enter

Enter passphrase (empty for no passphrase):

Tekan Enter sekali lagi

Enter same passphrase again:

Akan muncul output seperti ini

Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
a9:49:2e:2a:5e:33:3e:a9:de:4e:77:11:58:b6:90:26 root@remote_host
The key's randomart image is:
+--[ RSA 2048]----+
|     ..o         |
|   E o= .        |
|    o. o         |
|        ..       |
|      ..S        |
|     o o.        |
|   =o.+.         |
|. =++..          |
|o=++.            |
+-----------------+

2. Ubah /etc/ssh/sshd_config di Server (192.168.1.10)
Ubah baris

PasswordAuthentication no

menjadi

PasswordAuthentication yes

Restart sshd

systemctl restart sshd

3. Copy rsa ke Server menggunakan perintah berikut di Client (192.168.1.20)

ssh-copy-id -i ~/.ssh/id_rsa.pub root@192.168.1.10

Bila ssh menggunakan port lain mis. port 2205

ssh-copy-id -p 2205 -i  ~/.ssh/id_rsa.pub root@192.168.1.10

Ketik yes, enter

The authenticity of host '192.168.1.10 (192.168.1.10)' can't be established.
ECDSA key fingerprint is fd:fd:d4:f9:77:fe:73:84:e1:55:00:ad:d6:6d:22:fe.
Are you sure you want to continue connecting (yes/no)? yes

4. Aktifkan SSH Agent dengan perintah di Client (192.168.1.20) (Abaikan step ini dan selanjutnya, apabila pada point 1 tidak input password)

exec ssh-agent $SHELL

5. Add Private Key ke Agent dengan perintah berikut di Client (192.168.1.20)

ssh-add

Masukkan password yang tadi di input, Kemudian Enter

Enter passphrase for key '/root/.ssh/id_rsa':

Selesai.
Selamat Mencoba

×

Hello!

Klik salah satu dibawah untuk chat WhatsApp atau kirim email kepada kami ke info@saad.web.id

× WhatsApp Kami