How to change the remote port of Linux cloud server

WBOY
Release: 2023-05-15 12:19:16
forward
1721 people have browsed it

Step one: Configure SSH

Edit the SSH configuration file:

vi /etc/ssh/sshd_config
Copy after login

Find the Port line and change the default 22 to the desired port, such as 2124.

Port 2124
Copy after login

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
Copy after login

CentOS 7

firewall-cmd --add-port 2124/tcp --permanent
firewall-cmd --add-port 2124/tcp
Copy after login

Step 3: Restart SSH

Execute the following command to restart the SSH service.

service sshd restart
Copy after login

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!

Related labels:
source:yisu.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!