How To Change Your SSH Port Number?

Modifying your SSH port is an important step in securing your VPS or dedicated server from abusive activity. This article will go over the procedure of changing the servers SSH port. You’ll need to log into your server using SSH. If you’re not certain about the basic ssh commands then consult our guide on useful commands to manage your Server through SSH.

ssh port number

This article requires editing of the key SSH file configurations. You can use any text editor you like, but. In this case we’ll use nano, the Linux Nano text editor.

When you’re in a position to begin, be sure to follow the next steps.

Step 1: Change your directory to /etc/ssh/ via the below command

cd /etc/ssh/

Step 2: Here, you need to make a backup of your current sshd_config for security side. To do this, run the below command

cp sshd_config sshd_config.bak

Step 3: You’ll now need to edit the sshd_config file using the below command

nano sshd_config

Step 4: In nano, search for the word “port” by using ctrl+w

Step 5: Once you able to locate the port setting, you can delete the # symbol to uncomment the line

Step 6: Change the port number, which should be 22, to any port you wish under eg 1981

Step 7: It is advised not to use the below ports as they are generally in use for the different services

25
53
110
443
495
21
80
2083
2082
2086
2087
2096
9876

You can always use command cat /etc/services to find which port numbers are configured on your server

Step 8: Finally restart the SSH service with the following command and changes will get applied.

service sshd restart

Thank you.

Scroll to Top