sshdでポート番号を変更
デフォルト設定がコメントアウトされているので、コメントアウト解除し、ポートを変更する
sudo vi /etc/ssh/sshd_config
#port 22
port 2222
再起動する
sudo service sshd restart
firewalldでsshのポートを開放する
デフォルトのssh用設定が存在するので/etc/firewalld/servicesにコピーしてポートを変更する
sudo cp /usr/lib/firewalld/services/ssh.xml /etc/firewalld/services/ssh.xml
sudo vi /etc/firewalld/services/ssh.xml
<?xml version="1.0" encoding="utf-8"?>
<service>
<short>SSH</short>
<description>Secure Shell (SSH) is a protocol for logging into and executing commands on remote machines. It provides secure encrypted communications. If you plan on accessing your machine remotely via SSH over a firewalled interface, enable this option. You need the openssh-server package installed for this option to be useful.</description>
<port protocol="tcp" port="2222"/>
</service>
リロードする
/etc/firewalld/services以下の変更済みファイルが読み込まれ、設定が反映される
sudo firewall-cmd --reload
参考
CentOS7のfirewalldでsshのポート番号を変更する方法
https://qiita.com/DQNEO/items/5780d81b2e0af4cc1544