How to change the SSH Port in Linux

By default SSH service runs on port 22. Running SSH service on port 22 is not secure as it can become an easy target for attackers who are scanning the network for open ports. By changing the default port, you can make it more difficult for attackers to find and exploit the SSH service.

To change SSH port, edit file

In the file, find the line

Change 22 to whatever port number you want. It is better to use a higher port number so it will be difficult for hackers to find.

Restart SSH service

On Debian/Ubuntu

On RHEL-based Linux (AlmaLinux, RockeyLinux, Oracle Linux, CentOS)

If you have a firewall, make sure you open the new port in the firewall.

See ssh

Need help with Linux Server or WordPress? We can help!

Leave a Reply

Your email address will not be published.