Change SSH ports

Linode Staff

I'm trying to re-assign my SSH port to another port, and it's not working. After making the change to /etc/ssh/sshd_config and applying it, the re-assigned port does not function, but SSH continues to listen on port 22. I have checked using lsof and netstat, and I see sshd running on the correct port in the outputs of each.

How can I correct this?

3 Replies

Without seeing the contents of your /etc/ssh/sshd_config file, or having visibility into your Linode’s [logs](https://www.linode.com/community/questions/295/how-do-i-check-my-servers-log-files it is difficult for me to say for certain what is happening here. My guess is that the config file probably looks right, since you’re seeing that SSH is listening on the correct port. It’s definitely odd that it’s responding on port 22 as well. If you could provide the output of sudo netstat -plunt (run this on your Linode), I’ll be able to review the output to see if I can identify anything that is off in the configuration. If you could also please provide the output of cat /etc/ssh/sshd_config | grep -I 'port', then it will help us identify if there are any conflicting settings that could explain the issue.

I should also point out that while changing SSH ports is a pretty common practice, it often results in more headache than it's worth. This is mainly because it obfuscates your configuration, without really providing any additional security benefit, as identifying which port the service has been moved to is fairly simple to do.

To best secure your SSH server, I recommend going through our guides on Securing your Server, and Use Advanced OpenSSH Features to Harden Access to Your Linode. Configuring things like Public Key Authentication and fail2ban will go much further in providing security for your Linode.

output of sudo netstat -plunt

Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State
tcp        0      0 127.0.0.53:53           0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:4411            0.0.0.0:*               LISTEN
tcp6       0      0 :::22                   :::*                    LISTEN
tcp6       0      0 :::4411                 :::*                    LISTEN
udp        0      0 127.0.0.53:53           0.0.0.0:*

output of cat /etc/ssh/sshd_config | grep -I 'Port'
there is no 'port' , it's the uppercase 'Port'

Port 4411
Port 22
#GatewayPorts no

Definitely you are right about he security of setting public key. I'll do that later after solving this problem.

Everything's fine before today's apt update. Maybe something got wrong there.

So has linode changed some rule about ssh?

For example, linode only allowed port 22 for ssh now?

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