How to change default SSH port on Linode
I'd be happy to provide some assistance to this. This procedure applies to changing the default ssh port to any port number of your choice.
First I recommend taking a backup of your Linode to restore back if things do not go as planned as configuration changes may cause unexpected behaviors.
Start by opening the
/etc/ssh/sshd_configconfiguration file with nano or your preferred text editor.
#Port 22line within the configuration file. You'll need to uncomment this line and change the number to our desired port number. For this example, we'll switch the port number to 9287.
From: #Port 22 To: Port 2222
Save the changes you made and exit the file editor.
Lastly, restart your sshd service by running
sudo systemctl reload sshd. Depending on your distribution, you might want to use this command instead
sudo systemctl restart sshd
Test your changes by connecting to your Linode using your new port with the
-poption in the command.
ssh -p 9287 [email protected]
where user is your desired login username and LinodeIP is the IP address of your Linode.
Our guide on Troubleshooting SSH has good information that should be helpful in resolving common SSH problems.
Linode Support Team