Login SSH Tanpa Password

Kita dapat melakukan login ke server lain tanpa memasukkan password hanya dalam beberapa langkah. Adapun command yang kita manfaatkan adalah ssh-keygen dan ssh-copy-id. Di dalam tulisan ini saya berikan contoh ssh remote dari server VPS saya enzu01.linboxs.net ke enzu02.linboxs.net.

Generate public dan private-key

Cukup ketikkan perintah ssh-keygen

# ssh-keygen

dan ikuti langkahnya seperti berikut:

[root@enzu01 ~]# ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
/root/.ssh/id_rsa already exists.
Overwrite (y/n)? y
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
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:
b7:ae:29:1f:59:02:40:0e:74:54:2e:ba:ec:f8:f7:a3 root@enzu01.linboxs.net
The key's randomart image is:
+--[ RSA 2048]----+
| .oo=.. |
| + o |
| o o |
| . . . |
| . S o |
| . . = . |
| o o . |
| o . o + |
|..o.Eo.++.. |

Salin public-key

Ketikkan perintah di bawah, agar public-key yang ada di server saat ini tersalin ke server tujuan.

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

dan ikuti langkahnya seperti berikut:

[root@enzu01 ~]# ssh-copy-id -i ~/.ssh/id_rsa.pub root@enzu02.linboxs.net
The authenticity of host 'enzu02.linboxs.net (' can't be established.
RSA key fingerprint is 48:a2:8f:d9:cd:84:02:4a:09:bf:45:ee:e7:29:36:c6.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'enzu02.linboxs.net,' (RSA) to the list of known hosts.
reverse mapping checking getaddrinfo for unt.cruactives.com [] failed - POSSIBLE BREAK-IN ATTEMPT!
root@enzu02.linboxs.net's password:
Now try logging into the machine, with "ssh 'root@enzu02.linboxs.net'", and check in:


to make sure we haven't added extra keys that you weren't expecting.

Test login SSH

Lakukan uji coba login ke server tujuan, apabila tidak muncul prompt password berartiĀ sekarang kita sudah bisa login ke server remote tanpa menggunakan password šŸ˜€

[root@enzu01 ~]# ssh root@enzu02.linboxs.net
reverse mapping checking getaddrinfo for unt.cruactives.com [] failed - POSSIBLE BREAK-IN ATTEMPT!
Last login: Fri Nov 13 22:08:45 2015 from
[root@enzu02 ~]#

Sekian, semoga bermanfaat.



Leave a Comment

Your email address will not be published. Required fields are marked *