How to Change Default SSH Port on Linux

r00t December 10, 2017

Change Default SSH Port on Linux

In this tutorial we will show you how to change default SSH port on Linux. We will also install and configure its prerequisites. Among those actions to secure your VPS would be to alter the default SSH port. Once you start using a non-default port, all links to the default port will be refused, thus increasing chances of your VPS to steer clear of common SSH scanners used by attackers. You may learn what needs to be changed in the VPS configuration in order to utilize a custom SSH port.

I recommend to use a minimal Ubuntu or CentOS server setup as a basis for the tutorial, that can be a virtual or a root server image with an Ubuntu 16.04 minimal install from a web hosting company or you use our minimal server tutorial to install a server from scratch.

Change Default SSH Port on Linux

Step 1. First, ensure your system and apt package lists are fully up-to-date by running the following:

apt-get update -y
apt-get upgrade -y

Step 2. Changing the port.

Once the system is updated, open the SSH configuration file with your favorite text editor and find the lines that specifies the SSH port:

nano /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, In this article we will use port 8888:

Port 8888

Now, restart the SSH service for the changes to take effect:

systemctl restart sshd

Congratulation’s! You have successfully change default SSH port on your Ubuntu 16.04 server. Thanks for using this tutorial how to change default SSH port on Linux system.

The Tags:

Leave a Comment

Comments are closed.