All Collections
VPS
How To Change Your SSH Port
How To Change Your SSH Port
Jamie G. avatar
Written by Jamie G.
Updated over a week ago

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:

  1. Login to Web Host Manager

  2. Click on Configure Firewall and Security

  3. Click on Firewall Configuration

  4. Enter 5622 in the TCP_IN field

  5. Click on Change at the bottom

  6. 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:

  1. Login to Web Host Manager

  2. 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)
Did this answer your question?