unix

How do I run sshd on another port instead of port 22?

Changing the port sshd runs on from port 22 to another port is really simple. You just need to update the /etc/sshd/sshd_config file to specify an alternate port.

# cat /etc/sshd/sshd_config
# This is ssh server systemwide configuration file.

Port 22
ListenAddress 192.168.1.1
HostKey /etc/ssh/ssh_host_key
ServerKeyBits 1024
LoginGraceTime 600
KeyRegenerationInterval 3600
PermitRootLogin no
IgnoreRhosts yes
IgnoreUserKnownHosts yes
StrictModes yes
X11Forwarding no
PrintMotd yes
SyslogFacility AUTH
LogLevel INFO
RhostsAuthentication no
RhostsRSAAuthentication no
RSAAuthentication yes
PasswordAuthentication yes
PermitEmptyPasswords no
AllowUsers admin

To change the port, simply update “Port 22” with the new port number. Once your config file is saved, restart sshd and you should be all set.

Keep in mind that you’ll now need to use ssh -p user@hostname as it will not work without the -p since the port has been changed to something other than 22.

Click to comment

Leave a Reply

Your email address will not be published. Required fields are marked *

To Top