Port 22 is used by default to establish an SSH connections. This port is automatically configured during the installation of your operating system.
To reduce the number of brute force attacks, you can change it to a different port for SSH access.
Changing the Default Port
To change the SSH port:
- Log on to the server as an root or an administrator user.
- Open the SSH configuration file sshd_config with the text editor nano :
$ nano /etc/ssh/sshd_config
- Search for the entry Port 22 (could be commented)
- Replace it with the desired value - port between 1024 and 65536
- Save and Restart the OpenSSH service
$ service ssh restart
# or
$ systemctl restart sshd
Top comments (4)
I'm not sure about such approach than using fail2ban or things like that.
Changing the port address is an obfuscation technique
Hi,
Check out this blog post
dev.to/rmaurodev/8-actions-for-har...
It has a more actions you can do.
This second article is indeed what i would at least recommend
I usually combine fail2band, different port number, do not allow password logins and dot not allow root user login.
This is just how to change the port number :)