What we will Cover in this Post:
Need Help?

We're always here for you. Submit a Ticket.

Contact Us

How to Change the Default SSH Port?

By Default, Port 22 is used to establish an SSH Connection. This Port is Automatically Configured during the Installation of your Operating System.

To Reduce the Number of Brute Force Attacks, you can Configure another Port for SSH Access (EG: 6543).

Getting Started

You will need to log in to your Server using SSH. Open your favourite SSH client or type this Command in your Terminal:

ssh root@your_server_ip

your_server_ip should be replaced with your Server IP Address.

Changing the SSH Port

Once you are logged in to your Server, we will need to change the /etc/ssh/sshd_config File.

Open this File with your favourite editor. For this tutorial, we will use nano. Use this Command to open the File:

nano /etc/ssh/sshd_config

Search for the Entry - Port 22.

If this Line is Commented (with # before Port 22), please Remove the #. Replace Port 22 with a Port between 1024 and 65536 (EG: 6543). All Brute Force Attacks happen on Port 22 and you will Avoid Many Attacks by using a Custom SSH Port.

Restart the SSH Service

In order for our changes to apply, we need to Restart the sshd Service. You can do this with this Command:

service sshd restart

NOTE: Please check if your Server has a Firewall Installed. If so, check the rules and add your new SSH Port to the Firewall Configuration. Otherwise, you might lockout yourself from SSH.