How to change the ssh port on Linux or Unix server - nixCraft

https://www.cyberciti.biz/faq/howto-change-ssh-port-on-linux-or-unix-server/

From the article :

When changing the port that sshd listens on , if SELinux is enabled, then you must run semanage to allow sshd to run on that new port.

For example. if you have changed sshd to listen on port 2222 , then you must [type the following command to change port to allow sshd to run on port 2222.

semanage port -a -t ssh_port_t -p tcp 2222

systemctl restart sshd`


If the port is already assigned in semanage , then you need to use -m instead of -a in your semanage command.
Otherwise semanage says “port already assigned” and when you restart sshd it fails.

see https://serverfault.com/questions/790404/selinux-error-valueerror-port-tcp-5000-already-defined

Here is a screenshot from my linux server: