Cheap VPS host selection
Provide server host evaluation information

How to set Centos7 remote port

To set the remote port on CentOS 7, follow the steps below:

  1. Log in to the CentOS 7 server and run the following command as root to open the specified port on the firewall:
     Firewall cmd -- zone=public -- add port=<port number>/tcp -- permanent # Add TCP port Firewall cmd -- zone=public -- add port=<port number>/udp -- permanent # Add UDP port Firewall cmd -- reload # Reload the firewall configuration

    If the firewall has been opened for the specified port, you can skip this step.

  2. If the SSH server has not been installed, run the following command to install the SSH server:
     yum install -y openssh-server
  3. Edit the SSH server configuration file to listen to the specified remote port. Run the following command to edit /etc/ssh/sshd_config File:
     vi /etc/ssh/sshd_config
  4. In the open file, find the following line, delete the comment mark (#) in front of it, and modify it to the desired remote port number:
     #Port 22 Port<remote port number>
  5. Save changes and close the file.
  6. Restart the SSH service to apply the changes:
     systemctl restart sshd

Now, your CentOS 7 server will listen to the specified remote port you just set. Please ensure that your firewall and router settings allow inbound and outbound connections for this port.

Do not reprint without permission: Cheap VPS evaluation » How to set Centos7 remote port