Introduction
It is a common problem that the server cannot be accessed via SSH after a system reboot following CloudLinux installation. This is usually due to the default settings in the sshd_config
file and the lack of firewalld
configuration. This article explains step by step how to change the SSH port and open the necessary ports in the firewall.
Cause of the Problem
-
The default SSH port (22) may sometimes be blocked by the system.
-
Some services may not be activated after a CloudLinux kernel update.
-
Access is not possible if special ports such as 1453, 2086, 2087 are not open in the Firewalld service.
Step-by-Step Solution
The following steps allow SSH connection to be made from a special port such as 1453
and introduce cPanel/WHM ports to the firewall.
1. Change the SSH Port
sudo sed -i 's/^#Port 22/Port 1453/' /etc/ssh/sshd_config
This command activates the Port 22
line, which is commented out in the sshd_config
file, and changes it to 1453.
2. Restart the SSH Service
sudo systemctl restart sshd
sudo systemctl enable sshd
In this step, the SSH service is restarted with the new port and it is ensured that it runs automatically when the system starts.
3. Open Ports via Firewalld
1453 for SSH:
sudo firewall-cmd --permanent --add-port=1453/tcp
For WHM/cPanel:
sudo firewall-cmd --permanent --add-port=2086/tcp
sudo firewall-cmd --permanent --add-port=2087/tcp
Reload the firewall:
sudo firewall-cmd --reload
Important Notes
-
To connect from the new SSH port:
ssh -p 1453 root@server_ip_address
-
Make sure you have an open connection in a separate terminal before making any port changes, otherwise you may lock yourself out of the system.
-
Ports 2086 (HTTP) and 2087 (HTTPS) must be open for WHM/cPanel access.
Conclusion
It is common to experience SSH and WHM connection problems when the system is restarted after CloudLinux installation. Therefore, sshd_config
editing, changing the SSH port and opening the necessary ports via firewalld is a basic requirement. By following these steps, you can easily solve access problems.