The default ssh port is 22. We strongly recommend that you change it to 10000 or above. In this way, the chances of other users scanning ports are also greatly reduced. Modification Method: # edit/etc/ssh/ssh_config
Vim/etc/ssh/ssh_config
# Add a new port value under host. Take 18439 as an example:
Port 22
Port 18439
# Edit/etc/ssh/sshd_config (same as Figure 2 above)
Vim/etc/ssh/sshd_config
# Add a new port value
Port 22
Port 18439
# Restart the SSH service after saving:
Service sshd restart
# Add the port number in the firewall after setting the Firewall
Vim/etc/sysconfig/iptables
-A RH-Firewall-1-INPUT-M state -- state new-m tcp-p tcp -- dport 18439-J accept
# Restart the Firewall
Here, I set two ports to prevent SSH from being unable to be accessed again due to modification errors.
Change the connection port of your SSH client (for example, Putty) and test the connection. If the new port can be connected successfully, edit the above two files and delete the configuration of port 22.
If the connection fails, use port 22 to connect and then reconfigure it.
After the port is successfully set, note that port 22 should be deleted from iptables, port 18439 of the new configuration should be added, and iptables should be restarted.