How to change default SSH port on Linode

Linode Staff

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 instead sudo 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

Don’t forget to update your firewall rules to reflect the new port number!

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct