Knowledgebase

How To Change Your SSH Port

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 root@192.168.161.1 (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 root@192.168.1.1 (replace with your server IP)
 
Was this answer helpful?

Related Articles

10 Minute VPS Hosting Setup With WordPress

15 Minute VPS Hosting Setup With WordPress I'll never forget my first dedicated...

Choosing A Web Server For Your VPS Hosting Package

Choosing A Web Server For Your VPS Hosting Package At AppsGators we currently have...

How To Deploy A Cloud Virtual Private Server (VPS)

How To Deploy A Cloud Virtual Private Server (VPS) Back in “the day” you would have to...

How To Disable Root Logins & Replace With SSH Key

How To Disable Root Logins & Replace With SSH Key The next thing you want to do is...

How To Enable HTTP/2 On Your cPanel VPS

How To Enable HTTP/2 On Your cPanel VPS Enable HTTP/2 Using Easy Apache 4 Those using...