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.
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.
- Add the new port number to the firewall rules 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.