Home

Changing the SSH port on Linux

Moving sshd off the default port 22 is a classic first step when hardening a Linux server. It cuts down the noise from automated scanners hammering 22. A couple of quick edits and you're done.

bash
nano /etc/ssh/sshd_config

Find the Port 22 line, change it to whatever port you want, and uncomment it.

Save and exit, then restart the SSH service:

Ubuntu:

bash
service ssh restart

Debian / Ubuntu (systemd):

bash
systemctl restart ssh

CentOS:

bash
systemctl restart sshd

Once the service is back up, connect on the new port.