VPS

How to Change SSH Port on Linux VPS

Introduction

One of the steps to secure your VPS is to change the default SSH port. Once you start using a non-default port, all connections to the default port will be denied, thus increasing chances of your VPS to stay away from common SSH scanners used by hackers. You will learn what needs to be changed in the VPS configuration in order to use a custom SSH port.

What you’ll need

Before you begin this guide you’ll need the following:

  • SSH root access to the VPS

Changing the port

Open configuration file of the SSH daemon by executing the following command:

nano /etc/ssh/sshd_config

Alternatively, you can use vim editor (it’s installed by default on all Linux distributions):

vim /etc/ssh/sshd_config

Locate this line:

# Port 22

Change it to any port you desire and remove # at the beginning. Save the changed file with CTRL+X (or COMMAND+X shortcut if you are on MAC).

In order for changes to take effect, you need to restart SSH daemon with this command:

service sshd restart

All is set, you have just changed your default SSH port. Do not forget that from now on you will be able to access the server only using the port that you have specified in the configuration.

Conclusion

Congratulations, you have just learned how to change SSH port and greatly increased the security of your server! This tutorial is one in the series of how to secure your VPS, do not hesitate to check them all.

About the author

Edgaras G.

Edgaras is a veteran server administrator at Hostinger. He makes sure that every server runs at full throttle and has all the latest technological advancements. When he's not working, Edgaras enjoys skiing and exploring the world.

Add Comment

Click here to post a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

[href]
[href]
More in VPS
How to Transfer Full cPanel Backup to VPS

Close