As it is widely known, the default remote port for the Linux operating system is 22. While this port provides administrators with a remote management access point, it also leaves a vulnerability for hacker attacks. Therefore, changing the default remote port of a Linux cloud server is a common strategy to enhance the security of the operating system. How do we do this? Follow the steps below.
Edit the SSH configuration file:
vi /etc/ssh/sshd_config
Locate the line with "Port" and change the default port 22 to the desired port, such as 2124.
Port 2124
This step can be skipped if a firewall is not in use. However, if the firewall is active, failing to update it after changing the remote port can result in remote access issues.
CentOS 7
firewall-cmd --add-port 2124/tcp --permanent
firewall-cmd --reload
Ubuntu
sudo ufw allow 2124/tcp
sudo ufw reload
Execute the following command to restart the SSH service.
service sshd restart
And just like that, we have successfully changed the remote port of the Linux cloud server from 22 to 2124.
23-02-2024 02:02:07
22-02-2024 03:19:32
22-02-2024 03:16:03
22-02-2024 03:14:03
22-02-2024 03:11:58