How to change default SSH port on Linode
Hi , I need help in changing the default SSH port 22 to 9287.
2 Replies
Hello there,
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_config
configuration file with nano or your preferred text editor.Look for
#Port 22
line 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 insteadsudo systemctl restart sshd
Test your changes by connecting to your Linode using your new port with the
-p
option in the command.
ssh -p 9287 user@LinodeIP
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.
Best,
I. Sackey
Linode Support Team