How to Change Your SSH Port

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.


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



  1. Here you’ll want to make a backup of your current sshd_config to do this run the following command



  1. You’ll now need to edit the sshd_config file via the following command



  1. In nano, search for the word “port” by pressing ctrl+w then typing in port and pressing enter
  2. 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


  1. Change the port number which should be 22 to any port you wish under 65535
  2. 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
  3. Finally restart the SSH service with the following command




Leave a Reply