Add the new port in firewall (previous port – 22 – is not removed with this command). After that, reload the firewall.
firewall-cmd --permanent --service="ssh" --add-port "1772/tcp"
firewall-cmd --reload
On the linux machines who have selinux, you need also to add it. Second command checks if it added successfully:
semanage port -a -t ssh_port_t -p tcp 1772
semanage port -l | grep ssh_port_t
Finally, change the sshd configuration file ( usually it is: /etc/ssh/sshd_config ) to add / change port to the desired one (ex. 1772), and restart sshd:
Port 1772 <— add or edit it
and do a restart of sshd service:
systemctl restart sshd
Some thoughts: if you do all that remotely you might want to keep the default port untill you are 100% sure the new port worked.