How do I change the default SSH port

Avatar Linode 6 days, 14 hours ago

I'm trying to change the default SSH port. How do I do that?

3 Replies

You can change the SSH port by editing your sshd_config. That file is located here:


You'll then need to edit the Port line. If there is a # in front of the line make sure to remove it.

Finally, run the following to restart SSH:

systemctl restart sshd

After that, you'll be able to connect to your Linode on the new port.

Do not forget to allow your new ssh port in iptables before you change it.

Also   don't   forget   that   after   you   change   the   SSH   port,   you   will   need   to   tell   your   SSH   client   to   connect   to   the   new   port   instead   of   the   default   port   22.   For   example,   if   your   new   SSH   port   is   4321,   you   would   initiate   a   connection   like   so:

ssh   username@123.456.78.999   -p   4321


Please enter an answer

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] (

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct