SSH service by default runs on port 22. You can change the port that your SSH service runs if you're behind a firewall that only allows other ports.
You can also change the port that your SSH server runs on to reduce automated attacks to the common SSH port, especially if it's directly exposed to the internet.
SSH can configured to run on ports other than 22 by configuring the Port option in the sshd configuration file.
$ ss -natp | grep 2022 $
$ sudo vi /etc/ssh/sshd_config
Make sure the line does not begin with # as it implies the line is commented and will be ignored.
$ sudo ufw allow 2022/tcp # Ubuntu/Debian $ sudo firewall-cmd --add-port=2022/tcp --permanent && sudo firewall-cmd --reload # CentOS / Red Hat success success
$ sudo semanage port -a -t ssh_port_t -p tcp 2022
semanage can be installed on CentOS or Red Hat systems using the following command:
$ sudo yum install --assumeyes policycoreutils-python
$ sudo systemctl restart sshd
$ ss -tlnp | grep 2022 LISTEN 0 128 *:2022 *:* LISTEN 0 128 :::2022 :::*
Comment anonymously. Login not required.