For server security reasons, we need to change the default SSH port. Next is how to change the SSH port on CentOS 7
1. Edit file /etc/ssh/ sshd_config
[root@dev ~]# nano /etc/ssh/sshd_config
2. Change the value port to the port you want
Port 12345
3. In centOS 7 SELinux must be active and only allow ssh via port 22, therefore we need to add a whitelist
[root@dev ~]# semanage port -a -t ssh_port_t -p tcp 12345
4. Open the new SSH firewall port by adding the following command
[root@dev ~]# firewall-cmd --permanent --zone=public --add-port=12345/tcp
5. Reload the firewall
[root@dev ~]# firewall-cmd --reload
6. Restart the ssh service
[root@dev ~]# systemctl restart sshd.service
7. Change the SSH port Done
* Sometimes there is -bash: semanage: command not found, you can see this for solving