In this article, we will explain how to modify the SSH server port number.
SSH or Secure Shell, is used to secure connections with remote hosts on the default port number 22. However, for security reasons or to thwart potential brute force attacks, you may wish to alter this default port to a different one.
Follow these steps to change the SSH port number:
- Log into your root account.
- To change the ssh port number, enter the following command:
- Now, as you can see, Port 22 is the current port number which we have disabled by adding # and Port 1927 is the new port number.
- After changing the SSH port number, you must execute the “systemctl restart sshd” command to ensure the changes take effect.
- To check or verfiy the sshd service status, use the following command line-
systemctl status sshd
- Now, you need to allow port 1927 through your firewall. Run the following command-
firewall-cmd --permanent --add-port=1927/tcp
- Verify the Firewalld status and you will observe that the Firewalld service has transitioned to an Active state, indicating it is currently running.
- Now, you can access your new server using the recently configured SSH port.
In this way, you can change or update you SSH server port number.