To change SSH port on SELinux enabled Linux server, do the following steps:
- Login to the server via SSH.
- Open SSH config file using
vi /etc/ssh/sshd_config
- Edit the file, remove
"#"
from SSH port line#Port 22
and change the default port (example:Port 2454
) - Now run
semanage port -a -t ssh_port_t -p tcp PORTNUMBER
- Add the new SSH port in the firewall
- Now restart the sshd service using
service sshd restart