1. Home
  2. Linux
  3. General
  4. How to Change SSH Port on Linux VPS

How to Change SSH Port on Linux VPS

How to Change SSH Port on Linux VPS
How to Change SSH Port on Linux VPS

 

Introduction

In order to properly secure your VPS, you may want to change the default SSH port. Note that, after you begin using a non-default port, every connection to the default port will be rejected which will increasing the chance your VPS has to reject common SSH scanners used by hackers. In this tutorial we will teach you what has to be changed in the VPS configuration so you are able to use a custom SSH port.

Prerequisites

For this tutorial you are going to require the following:
– SSH root access to the VPS

Changing the port                                                                 

Open the ‘configuration’ file of the SSH daemon by running the command below.
nano /etc/ssh/sshd_config
You could also use the vim editor, which is installed by default on every linux distribution.

vim /etc/ssh/sshd_config

Look for the line below:

# Port 22

Replace it with any port you would like and delete the ‘%’ at the start. Then, save the changed file with CTRL+X or CMD+X if you are using MAC.

For this to take effect, you will have to restart the SSH daemon using the command below.

service sshd restart

Everything should now be set, you have just changed your default SSH port. Be sure to remember that, from now on, you are going to be able to access the server using only the port that you have specified in the configuration.

Conclusion

Congratulations, you now know how to change the SSH port and highly increase the security of your server.

Updated on December 23, 2018

Was this article helpful?

Related Articles

Leave a Comment

[apsl-login-lite login_text='Please login with a social account']