Tips Mengaktifkan Two Factor Authentication Pada SSH

  • choirrulloh
  • Nov 21, 2019

Pendahuluan

Keamanan pada zaman ini sangat diperhatikan pada zaman yang serba online seperti saat ini. Banyak cara yang dilakukan oleh Sysadmin untuk mengamankan segala informasi yang berada di server hingga sampai pada pengguna. Mulai dari proses memberikan password dengan kriteria password, mengubah port yang digunakan, metode autentikasi, dsb. Khusus untuk me-remote server Linux, protokol yang disarankan adalah SSH dan menggunakan ssh-key sebagai metode autentikasinya. Selain ssh-key ada juga metode yang lain, yaitu menggunakan Google Authenticator.

Google Authenticator sebuah aplikasi untuk melakukan generate password 2 langkah verifikasi.

Konfigurasi Two Factor SSH Di Ubuntu

Kebutuhan

  • Ubuntu 16.04 / 18.04
  • Handphone Diinstall aplikasi Google Authenticator (iPhone atau Android)
  • Akses root
  1. Install paket google authenticator di Ubuntu
    apt install libpam-google-authenticator
  2. Konfigurasi SSH Server
    Edit file /etc/pam.d/sshd tambahkan perintah dibawah ini di baris paling akhir:

    auth required pam_google_authenticator.so

    Sekarang edit file /etc/ssh/sshd_config dari no ke yes untuk mengaktifkan penggunaan Authenticator saya menambahkan ke konfigurasi pam.

    # Change to yes to enable challenge-response passwords (beware issues with
    # some PAM modules and threads)
    ChallengeResponseAuthentication yes

    Restart service SSH

    service sshd restart
  3. Konfigurasi Google Authenticator di Ubuntu
    Jalankan perintah dibawah ini untuk melakukan verifikasi ke aplikasi google Authenticator

    google-authenticator

    Nanti akan muncul seperti dibawah ini ikuti perintah yang di tebalkan

    Do you want authentication tokens to be time-based (y/n) y
    Warning: pasting the following URL into your browser exposes the OTP secret to Google:
      https://www.google.com/chart?chs=<>
    
    << ------ Di sini adalah Kode QR untuk melakukan scan terhadap aplikasi google authenticator ---------- >>
    
    << ------ Di sini juga adalah secret key dan backup codes ------ >>
    
    Do you want me to update your "/home/user/.google_authenticator" file? (y/n) y
    
    Do you want to disallow multiple uses of the same authentication
    token? This restricts you to one login about every 30s, but it increases your chances to notice or even prevent man-in-the-middle attacks (y/n) y
    
    By default, a new token is generated every 30 seconds by the mobile app. In order to compensate for possible time-skew between the client and the server, we allow an extra token before and after the current time. This allows for a time skew of up to 30 seconds between authentication server and client. If you experience problems with poor time synchronization, you can increase the window from its default size of 3 permitted codes (one previous code, the current code, the next code) to 17 permitted codes (the 8 previous codes, the current
    code, and the 8 next codes). This will permit for a time skew of up to 4 minutes between client and server.
    Do you want to do so? (y/n) y
    
    If the computer that you are logging into isn't hardened against brute-force login attempts, you can enable rate-limiting for the authentication module. By default, this limits attackers to no more than 3 login attempts every 30s. 
    Do you want to enable rate-limiting? (y/n) y
    
    

    Untuk konfigurasi 2TFA ssh sudah selesai. Sekarang ketika melakukan login ssh harus memasukkan kode verifikasi yang dikirimkan di handphone.

    [root@linux choirrulloh]# ssh root@157.245.206.218
    Password: 
    Verification code:  (ini diisi kode verifikasi dan tidak akan terlihat seperti ketika memasukkan password linux.)

2 thoughts on “Tips Mengaktifkan Two Factor Authentication Pada SSH

Leave a Reply to Ahmad ImanudinCancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.