Konfigurasi Remote Server SSH dengan Authentication Key




Konfigurasi Remote Server SSH dengan Authentication Key - SSH atau Secure Shell adalah salah satu protokol yang menggunakan enkripsi data untuk meremote dan berkomunikasi dengan server.

Pada tutorial kali ini, anda bisa meremote dengan metode authentication keys, authentication keys terdiri dari sepasang key. Private key yang digunakan oleh client dan harus disimpan secara aman. Sedangkan Public Key di upload ke server untuk mengenkripsi data dari Private Key yang cocok.





Instalasi ssh server (mode root)

apt-get install openssh-server

tunggu sampai proses instalasi selesai.
sampai disini sebenarnya user sudah bisa remote SSH via putty atau terminal dengan port default 22.

Konfigurasi SSH Keys

Langkah pertama, login sebagai user biasa dari komputer lokal untuk membuat ssh-keys itu sendiri. Anda cukup mengetikkan command berikut ini.

ssh-keygen -t rsa -b 4096

dengan command tsb, akan dibuat sepasang key dengan enkripsi 4096 bit.

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

lalu isikan informasi - informasi yang dibutuhkan. Pada pilihan passphrase anda bisa mengisinya atau tidak karena ini opsional, Tekan enter jika sudah selesai.

Your identification has been saved in /home/user/.ssh/id_rsa.
Your public key has been saved in /home/user/.ssh/id_rsa.pub.
The key fingerprint is:
73:7b:dc:c0:32:67:c1:24:09:c8:55:48:5c:5e:cd:9e user@remote_hostname
The key's randomart image is:
+--[ RSA 4096]----+
|     . =+=+.oo          |
|      o o..=  o            |
|          . o. . |
|           . .E   |
|        S + =              |
|         o B o            |
|          . o .              |
|           .                 |
|                             |
+-----------------+



Dengan ini maka sepasang ssh keys telah dibuat pada direktori /home/user/.ssh. Private key telah dibuat dengan nama file id_rsa, begitu juga dengan public key dengan nama file id_rsa.pub.

Kemudian anda hanya perlu mengupload public key ke directory salah satu user yang ada pada komputer server.


Upload public key ke server

Gunakan command dibawah untuk mengupload public key

ssh-copy-id user@remote_hostname

Ganti user dengan nama user yang ada di sistem server, dan ganti remote_hostname dengan IP Address dari server. 
Kemudian server akan menanyakan password dari user yang dituju.

anwar@RouterID:~/.ssh$ ssh-copy-id khoirul@192.168.0.11
##################################
#                      WELCOME BACK SIR!!                    #
#          I HOPE CAN DO THE BEST FOR YOU       #
#                           *******()*******                     #
##################################
##################################
#                                #        #   #                              #
#                             #         #        #                           #
#                           #         #            #                         #
#                             #     #           #                            #
#                               # #          #                               #
##################################
khoirul@192.168.0.11's password:
Now try logging into the machine, with "ssh 'khoirul@192.168.0.11'", and check in:

  ~/.ssh/authorized_keys

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

anwar@RouterID:/~.ssh$ 

Dapat disimpulkan public key milik user anwar telah ada di komputer server di directory ~/.ssh/ dengan nama file authorized_key kepunyaan user khoirul


Pengujian via komputer lokal 

Setelah proses upload public key selesai, anda bisa mencoba login dengan user yang memiliki public key tsb.

anwar@RouterID:~/.ssh$ ssh khoirul@192.168.0.11

##################################
#                      WELCOME BACK SIR!!                    #
#          I HOPE CAN DO THE BEST FOR YOU       #
#                           *******()*******                     #
##################################
##################################
#                                #        #   #                              #
#                             #         #        #                           #
#                           #         #            #                         #
#                             #     #           #                            #
#                               # #          #                               #
##################################

Linux serverID 3.2.0-4-686-pae #1 SMP Debian 3.2.41-2 i686

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
You have new mail.
Last login: Tue Jul  5 07:56:58 2016 from router.org
khoirul@serverID:~$ 


Maka user anwar yang meremote server dari komputer lokal tidak memerlukan password.
Namun hanya perlu private key untuk bisa login ke komputer server dengan user khoirul yang sebelumnya juga telah mempunyai public key.


Sekian & Terimakasih



source : https://www.digitalocean.com/community/tutorials/how-to-configure-ssh-key-based-authentication-on-a-linux-server

Previous
Next Post »

4 comments

Write comments

Njir, ntap nih blog pemrograman :D

Reply
avatar

Masukin commandnya di command promt bukan gan?

Reply
avatar
Unknown
AUTHOR

Itu command diatas di terminal semua gan, command prompt-nya linux

Reply
avatar
fei
AUTHOR

wah bagus ya ijin nyoba

Reply
avatar