-
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. -
If the SSH server has not been installed, run the following command to install the SSH server: yum install -y openssh-server -
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 -
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> -
Save changes and close the file. -
Restart the SSH service to apply the changes: systemctl restart sshd