Edit the SSH configuration file:
vi /etc/ssh/sshd_config
Find the Port line and change the default 22 to the desired port, such as 2124.
Port 2124
If you are not using a firewall, this step can be ignored. If the firewall is enabled and the firewall is not updated after changing the remote port, remote access will not be possible.
CentOS 6
iptables -I INPUT -p tcp --dport 2124 --syn -j ACCEPT service iptables save semanage port -a -t ssh_port_t -p tcp 2124
CentOS 7
firewall-cmd --add-port 2124/tcp --permanent firewall-cmd --add-port 2124/tcp
Execute the following command to restart the SSH service.
service sshd restart
In this way, we successfully changed the remote port of the Linux cloud server from 22 to 2124.
The above is the detailed content of How to change the remote port of Linux cloud server. For more information, please follow other related articles on the PHP Chinese website!