Change ssh port on centos

Edit the Port directive in /etc/ssh/sshd_config

# If you want to change the port on a SELinux system, you have to tell
# SELinux about this change.
# semanage port -a -t ssh_port_t -p tcp #PORTNUMBER
Port 12345
#AddressFamily any
#ListenAddress ::

After writing the change run:

[root@localhost ~]# semanage port -a -t ssh_port_t -p tcp 12345

To tell SELinux that ssh uses that port
Open the port to the outside world:

[root@localhost ~]# firewall-cmd --zone=public --add-port=12345/tcp --permanent
[root@localhost ~]# firewall-cmd --reload

Check that the changes took effect:

[root@localhost ~]# iptables-save | grep 12345
-A IN_public_allow -p tcp -m tcp --dport 12345 -m conntrack --ctstate NEW -j ACCEPT

[root@localhost ~]# semanage port -l  | grep ssh
ssh_port_t                     tcp      12345, 22

Reload ssh

[root@localhost ~]# systemctl reload ssh