Articles on: VPS

How To Change Your SSH Port



Change Your SSH Port In Web Host Manager



By default, SSH listens on port 22. This is the first thing a potential attacker is going to try.

I recommend changing this to a random four-digit number such as 5622.

To do this, you have to first open the port in the CSF firewall:

Login to Web Host Manager

Click on Configure Firewall and Security

Click on Firewall Configuration

Enter 5622 in the TCP_IN field

Click on Change at the bottom

Restart CSF

Once the port has been opened in the firewall, you then need to SSH into the server and modify the SSH configuration file.

If you’re using a Mac you can go to Utilities -> Terminal and SSH into your server:

ssh [email protected] (replace with your server IP)


Enter your password and type in:

locate sshd_config


Most of the time this is located in /etc/ssh/ – it could be different and mlocate will help you find it.

Once you have the full path to the file, use nano to edit it:

nano /etc/ssh/sshd_config


Uncomment where it says Port 22 and change this to 5622. Command + X (on a Mac) to exit, type Y (for yes) to save, and then exit.

You then need to start SSH inside of Web Host Manager:

Login to Web Host Manager

Click on SSH Server (Open SSH) under Restart Services

Congratulations – your SSH port has now been changed to 5622. It’s important to note, the next time you SSH into your server, you need to us -p to define the port:

ssh -p 5622 [email protected] (replace with your server IP)

Updated on: 10/10/2024

Was this article helpful?

Share your feedback

Cancel

Thank you!