Search The Hostwinds Guides Knowledge Base

How To Change Your SSH Port

Share:

How To Change Your SSH Port

Changing your SSH port can be a very important step when securing your VPS against potential malicious activity. This article will cover the process of changing your servers SSH port. You’ll need to be logged into your server via SSH, if you’re not sure how to access your server via SSH, please refer to our guide: Connecting to Your Server via SSH

 

This article requires the editing of key SSH configuration files. You can use any text editor that you’d like, however for this article we will be using the Linux text editor nano. Once you’re are ready to proceed, please refer to the following steps.

 

Step 1:  Change your directory to /etc/ssh/  via the following command

 

 

 

Step 2: Here you’ll want to make a backup of your current sshd_config to do this run the following command

 

 

 

Step 3:  You’ll now need to edit the sshd_config file via the following command

 

 

 

Step 4:  In nano, search for the word “port” by pressing ctrl+w then typing in port and pressing enter

Step 5:  Once you locate the port setting you can delete the # symbol to uncomment the line

 

Showing how to uncomment the port number setting for SSH

 

Step 6:  Change the port number which should be 22 to any port you wish under 65535

Step 7:  It is advised to not use the following ports as they are generally in use

  1. 25
  2. 110
  3. 443
  4. 495
  5. 21
  6. 80
  7. 2083
  8. 2082
  9. 2086
  10. 2087
  11. 2096
  12. 9876

 

You can always cat /etc/services  to find which port numbers are configured on your server

 

Step 8:  Finally restart the SSH service with the following command

 

 

 

Helpful Related Articles


Share:

Leave a Reply

Your email address will not be published. Required fields are marked *