Modify the default SSH port number in CentOS/Linux
In Linux, the default SSH port number is 22. Because this is a known port number, port 22 is scanned when an intruder scans the port, we can immediately know that this is the port number for SSH Login. Therefore, we need to modify the default port number so that intruders cannot immediately know the port function even if they scan the port number.
CentOS is 6.5
1. Open firewall ports
Here we want to change the default ssh port 22 to 2121, so we need to open port 2121 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
In this case, port 22 cannot be used for ssh remote connection. Port 2121 must be used.
How to Improve the SSH login authentication speed of Ubuntu
Enable the SSH service to allow Android phones to remotely access Ubuntu 14.04
How to add dual authentication for SSH in Linux
Configure the SFTP environment for non-SSH users in Linux
Configure and manage the SSH service on Linux
Basic SSH tutorial