Mengubah Port SSH 22 pada OS Almalinux 8

Akses SSH adalah merupakan akses port yang penting dalam sebuah server, namun seluruh os awal terinstall selalu menggunakan default port 22, hal ini menjadi kerentanan keamanan server. Dengan membiarkan port 22 terbuka, maka port ini akan dengan mudah di lakukan attack dengan cara bruteforce attack login.

Sehingga pada saat anda tetap menggunakan port 22 untuk login ke ssh , tak heran bila pasti ada info bahwa disana tertulis .. failed login . Biasanya banyak sekali failed login.

Untuk itulah sangat di sarankan anda mengubah port standard 22 ini ke angka yang berbeda untuk keamanan yang lebih maksimal .

Cara Mengubah Port SSH 22 pada OS Almalinux 8 ke port berbeda adalah :

Silahkan login ke ssh standart 22 terlebih dahulu kemudian :

Step awal : Ubah file /etc/ssh/sshd_config denga editor favourite anda , kami biasa menggunakan nano

nano /etc/ssh/sshd_config 

Akan muncul deretan kode sbb :

#       $OpenBSD: sshd_config,v 1.103 2018/04/09 20:41:22 tj Exp $

# This is the sshd server system-wide configuration file.  See
# sshd_config(5) for more information.

# This sshd was compiled with PATH=/usr/local/bin:/usr/bin:/usr/local/sbin:/usr$

# The strategy used for options in the default sshd_config shipped with
# OpenSSH is to specify options with their default value where
# possible, but leave them commented.  Uncommented options override the
# default value.

# If you want to change the port on a SELinux system, you have to tell
# SELinux about this change.
# semanage port -a -t ssh_port_t -p tcp #PORTNUMBER
#
#Port 22
#AddressFamily any
#ListenAddress 0.0.0.0

cek baris yang kami berikan penebalan ya , misal kita akan menggunakan port : 6781

Hilangkan tanda # , kemudian ubah angka nya ke 6781 sehingga hasilnya :

#       $OpenBSD: sshd_config,v 1.103 2018/04/09 20:41:22 tj Exp $

# This is the sshd server system-wide configuration file.  See
# sshd_config(5) for more information.

# This sshd was compiled with PATH=/usr/local/bin:/usr/bin:/usr/local/sbin:/usr$

# The strategy used for options in the default sshd_config shipped with
# OpenSSH is to specify options with their default value where
# possible, but leave them commented.  Uncommented options override the
# default value.

# If you want to change the port on a SELinux system, you have to tell
# SELinux about this change.
# semanage port -a -t ssh_port_t -p tcp #PORTNUMBER
#
Port 6781
#AddressFamily any
#ListenAddress 0.0.0.0

Setelah itu tekan CTRL + O , kemudian tekan enter untuk menyimpan , setelah selesai tekan CTRL + X untuk keluar

Kemudian restart sshd servicenya dengan cara :

systemctl restart sshd

Oh ya , sampai sini jangan senang dulu ya , apabila anda sebelumnya sudah install panel hosting misal cpanel atau directadmin jangan lupa allow port di atas ya ke firewall, dalam hal ini : 6781.

Apabila menggunakan CSF ( Config Server Firewall ) , masuk ke configuration , masukkan angka 6781 pada TCP IN dan Out nya contoh :

Kemudian Save dan Restart CSF .

Pada dasarnya step step di atas sudah cukup dan bisa langsung menggunakan login ssh dengan port baru 6781 tersebut. Namun peru di ingat bila :

Saya sudah set seperti di atas, namun saya tetap tidak bisa akses port tersebut, apa yang salah ?

FYI : CSF dan basic OS biasanya ada namanya IPTABLES service seperti yang digunakan pada CSF. Bila mengalami masalah seperti di atas, artinya port juga harus di buka di IPTABLES nya ya guys caranya adalah :

iptables -A INPUT -i eth0 -p tcp --dport 6781 -m state --state NEW,ESTABLISHED -j ACCEPT

Untuk Allow akses masuk ke port 6781 , kemudian

iptables -A OUTPUT -o eth0 -p tcp --sport 6781 -m state --state ESTABLISHED -j ACCEPT

Setelah selesai silahkan di coba akses ssh anda dengan port baru nya .

Selamat mencoba . Ikuti terus blog atriumhosting

Atrium Hosting

Mengganti SSH Default Port Pada Ubuntu LTS 22

5/5 - (9 votes)
  • Admin Staff
  • Bila anda membutuhkan layanan seperti :
    - Hosting
    - Domain
    - VPS / Dedicated Server
    - Email Hosting , Google Workspace
    - Reseller Hosting

    Silahkan lgs ke web kami di AtriumHosting.Com
    WhatsApp Center : 081237908888
    Live Chat Website
    Telegram : 081237908888

Exit mobile version