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:

  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)
 
  •  
  • ssh
  • 2 Users Found This Useful
Was this answer helpful?

Related Articles

How to Disable root logins

How To Disable Root Logins Most Linux installations come with the root user by...

How to give a user sudo privileges

Testing for Sudo Permissions Before making any changes, you can first check to see whether you...

How To Enable Let's Encrypt Auto SSL

How To Enable Let's Encrypt Auto SSL One of the final things I recommend is integrating your VPS...