Mengubah Port SSH di CentOS 7

Ubah port didalam file konfigurasi sshd

sudo nano /etc/ssh/sshd_config
# 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 8023
#AddressFamily any
#ListenAddress 0.0.0.0
#ListenAddress ::

Izinkan di firewall-cmd

firewall-cmd --add-port=8023/tcp --permanent

Reload firewall-cmd

firewall-cmd --reload

Coba restart service ssh

systemctl restart sshd

Jika pada saat melakukan restart service ssh menemukan error seperti beriku:

Job for sshd.service failed because the control process exited with error code. See "systemctl status sshd.service" and "journalctl -xe" for details.

Kita harus bind port di SELinux

yum -y install policycoreutils-python

Lalu ketikkan perintah berikut

semanage port -a -t ssh_port_t -p tcp 8023

Lakukan restart service ssh kembali.

systemctl restart sshd

Pastikan tidak ada error yang muncul.

Dan selamat! port SSH sudah berhasil diubah.