You can also find a detailed article on how to change the SSH Port for CentOS 7 operating system users.
If you want to change the default SSH port number in CentOS 7, you can perform the following steps.
1. Let's back up the sshd_config file.
cp / etc / ssh / sshd_config /etc/ssh/sshd_config.bak
2. Change the port number
nano -w / etc / ssh / sshd_config
We remove the # at the beginning of the #Port line in the opened file and enter the port number we want to use.
Save with ctrl + x and exit.
3. Allow access to the port.
semanage port -a -t ssh_port_t -p tcp PORTFIELD
If you get an error in command not found, let's download the following library.
yum -y install policycoreutils-python
4. Restart the SSH service.
systemctl restart sshd.service