Home  >  Article  >  Operation and Maintenance  >  How to change the remote port of Linux cloud server

How to change the remote port of Linux cloud server

WBOY
WBOYforward
2023-05-15 12:19:161689browse

Step one: Configure SSH

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

Step 2: Update the firewall

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

Step 3: Restart SSH

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!

Statement:
This article is reproduced at:yisu.com. If there is any infringement, please contact admin@php.cn delete