DenyHosts: Utility Sys Admin Melawan SSH Cracker

Bagi seorang sys admin, menjaga kemanan server ubuntu sama halnya seperti seorang penjaga kemanan mengamankan rumah/gedung. Jika servernya bisa ditembus dan password root didapat oleh penyerang (hacker/cracker), maka bisa lemeslah sang sys admin hehehehe. Dari beberapa utility yang ada untuk lebih mengamankan server ubuntu, salah satunya adalah DenyHosts.
DenyHosts (www.techmint.com)
DenyHosts secara otomatis akan memblok koneksi serangan brute force attack melalui SSH (default di port 22) dengan mekanisme membatasi jumlah autentikasi login, kemudian secara otomatis pula akan menambahkan daftar alamat IP si penyerang ke file /etc/hosts.deny. Berikut langkah-langkah instalasinya:
  1. Buka alamt website dibawah ini:
    https://launchpad.net/ubuntu/trusty/+package/denyhosts
  2. Kemudian pilih berdasarkan konfigurasi sistem server ubuntu yang kita punya. Kebetulan sistem ubuntu server saya berbasiskan i386. Versi terbaru dari DenyHosts pada saat tulisan ini dibuat adalah versi 2.6-10. Pada bagian "downloadable file" kopikan alamat link DenyHosts
    Versi DenyHosts
  3. Selanjutnya diterminal ubuntu, downloadlah file tersebut diatas menggunakan perintah wget:
    # wget http://launchpadlibrarian.net/83013937/denyhosts_2.6-10_all.deb
    --2014-09-23 18:50:40--  http://launchpadlibrarian.net/83013937/denyhosts_2.6-10_all.deb
    Resolving launchpadlibrarian.net (launchpadlibrarian.net)... 91.189.89.229, 91.189.89.228
    Connecting to launchpadlibrarian.net (launchpadlibrarian.net)|91.189.89.229|:80... connected.
    HTTP request sent, awaiting response... 200 OK
    Length: 66134 (65K) [application/x-debian-package]
    Saving to: ‘denyhosts_2.6-10_all.deb’

    100%[=======================================================================>] 66,134       153KB/s   in 0.4s

    2014-09-23 18:50:46 (153 KB/s) - ‘denyhosts_2.6-10_all.deb’ saved [66134/66134]
  4. Langkah berikutnya adalah menginstall paket denyhosts ke dalam sistem:
    # dpkg -i denyhosts_2.6-10_all.deb
    Selecting previously unselected package denyhosts.
    (Reading database ... 112091 files and directories currently installed.)
    Preparing to unpack denyhosts_2.6-10_all.deb ...
    Unpacking denyhosts (2.6-10) ...
    Setting up denyhosts (2.6-10) ...
     * Starting DenyHosts denyhosts                                                                           [ OK ]
    Processing triggers for man-db (2.6.7.1-1) ...
    Processing triggers for ureadahead (0.100.0-16) ...
  5. Aplikasi denyhosts sudah berjalan, untuk melihat daftar ip yang diblok oleh sistem terdapat di file: /etc/hosts.deny.
  6.  Contoh daftar IP yang diblok pada file /etc/hosts.deny:
    sshd: 217.109.96.243
    sshd: 216.99.147.239
    sshd: 124.95.165.180
    sshd: 162.243.0.85
    sshd: 60.248.96.128
    sshd: 121.52.215.243
    sshd: 112.216.82.130
    sshd: 58.20.178.174
    sshd: 82.165.195.40
    sshd: 119.147.26.176
    sshd: 218.28.116.227
    sshd: 112.65.178.196
    sshd: 62.76.191.213
    sshd: 61.164.110.112
    sshd: 123.30.238.220
    sshd: 192.210.235.183
    sshd: 42.96.198.214
    sshd: 122.154.50.239
    sshd: 188.165.234.145
    sshd: 211.43.213.64
    sshd: 119.84.63.30
  7. Untuk melihat log aktivitas user yang mencoba masuk ke sistem melalui ssh, dapat dilihat di log autentikasi dengan perintah dibawah ini:
    # more /var/log/auth.log | grep sshd
    Sep 23 18:32:36 server sshd[18550]: Invalid user a from 124.90.231.248
    Sep 23 18:32:36 server sshd[18550]: input_userauth_request: invalid user a [preauth]
    Sep 23 18:32:36 server sshd[18550]: pam_unix(sshd:auth): check pass; user unknown
    Sep 23 18:32:36 server sshd[18550]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=124.90.231.248
    Sep 23 18:32:38 server sshd[18550]: Failed password for invalid user a from 124.90.231.248 port 30489 ssh2
    Sep 23 18:32:38 serer sshd[18550]: Received disconnect from 124.90.231.248: 11: Bye Bye [preauth]
    Sep 23 18:32:45 server sshd[18552]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=124.90.231.248  user=root
    Sep 23 18:32:47 server sshd[18552]: Failed password for root from 124.90.231.248 port 31565 ssh2
    Sep 23 18:32:47 server sshd[18552]: Received disconnect from 124.90.231.248: 11: Bye Bye [preauth]
    Sep 23 18:32:54 serever sshd[18554]: Invalid user postgres from 124.90.231.248
    Sep 23 18:32:54 server sshd[18554]: input_userauth_request: invalid user postgres [preauth]
    Sep 23 18:32:54 server sshd[18554]: pam_unix(sshd:auth): check pass; user unknown
    Sep 23 18:32:54 server sshd[18554]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=124.90.231.248

    ----contoh sebagian login ssh dengan user root yang gagal berdasarkan output perintah diatas----
  8.  Langkah selanjutnya kita bisa menganalisa setiap IP (kalau mau) dengan bantuan website seperti http://ip-lookup.net/.

Komentar

Most Popular Posts