In Linux, the default SSH port number is 22, because this is known as the port number, once the intruder to scan the port of 22 port, we immediately know that this is the port number for SSH login, so we need to modify the default port number, Allowing intruders to scan out port numbers does not immediately know what this port does.
1. Modify Firewall port number
Here we are going to change the default SSH port 22 to 2121, so the 2121 port is opened in the firewall
#/sbin/iptables-i input-p TCP--dport 2121-j accept#/etc/rc.d/init.d/iptables save# sed-i "/a input-m state--state New-m tcp-p TCP--dport 22-j accept/d "/etc/sysconfig/iptables# service iptables restart
2. Modify the Sshd_config file
# sed-i ' s/#Port 22/port 2121/'/etc/ssh/sshd_config
3. Restart the SSH service
# Service Sshd Restart
You cannot use port 22 for SSH remote connection at this time, you must use port 2121.
Linux/centos to modify the SSH default port number