This article will provide a guide for how to change SSH port in CentOS 7 server. For server administrators, you may want to help secure your CentOS VPS or dedicated servers by changing the port used to access SSH interface.
Changing the SSH port is considered a good security practice to circumvent the brute force attempts on port 22.
How to Change SSH Port in CentOS 7 Server
To change SSH port in CentOS 7 server, follow these instructions:
- Login to the server via SSH.
- Disable SELinux.
- Access the SSH configuration using the following command:
nano /etc/ssh/sshd_config
- Locate the line containing "#Port 22":

- Uncomment the line and change the port to your desired SSH port number (i.e. Port 7299):

- Exit and save the file.
- Open the new port number in the firewall to allow access:
sudo firewall-cmd --zone=public --permanent --add-port=7299/tcp --reload
- Restart sshd service:
sudo systemctl restart sshd
- Login to SSH using the new port number.
Conclusion
You now know how to change SSH port in CentOS 7 server.

👀 Choose SSD-powered VPS servers for increased speed, power, and security! Now 50% off- starting from only $3.19/mo.

