Dandandin.net

 

How to change the SSH port

When I set up my server, I decided to keep the SSH port at its default value for those three reasons:

  1. Worried to make the configuration file corrupted and not being able to log in anymore.
  2. Worried about some incompatibilities with some SSH software.
  3. With a port scanner it's trivial to find the new SSH

Of course I didn't leave the server in the wild with default settings:

  1. Access via preshared key with a long passphrase
  2. Configured Shorewall to slow down access to the port 22 (at most 1 request per minute)
  3. Set fail2ban to block access for 24 hours to who inputted the wrong password for more than three times
  4. Set fail2ban to send me an email in case of hacking

Recently, there was an attack from Korea with hundreds of logins.

Initially I decided to ignore the matter, then I said "Hey, changing the ssh port it's trivial!", so here is how to do that on Debian/Ubuntu:

nano /etc/ssh/sshd_config

Then change the port here:

# What ports, IPs and protocols we listen for
Port 2200

Then, restart the SSH daemon

/etc/init.d/ssh restart

Voila!

https://old.dandandin.net/how-to-change-the-ssh-port