Change SSH running port
SSH by default runs on port 22.There are times however that it need to be run on other ports, say when the firewall only allow certain ports but not port 22, or just to prevent from SSH bruteforce from bots that automatically attack port 22.
Which port SSH daemon is run is set by the Port option in the /etc/sshd_config configuration file. If it is not set, SSH daemon will run on it’s default port.
To make it run on port 2222, change the line (or add if it doesn’t exist) to the following.
Port 2222
To have the changes take effect, the SSH daemon need to reload the edited configuration file with the following command;
# /etc/init.d/ssh reload
In some Linux distribution, the command is as the following;
# /etc/init.d/sshd reload