To change the OpenSSH port number on RHEL 6 with SELinux enabled, you can use the following steps:
/etc/ssh/sshd_config
file and change the Port
setting to the desired port number. For example, to change the port number to 1255:sudo nano /etc/ssh/sshd_config
Change the following line:
#Port 22
To:
Port 1255
Save and close the file.
sudo service ssh restart
semanage
command:sudo semanage port -a -t ssh_port_t -p tcp 1255
This will update the SELinux policy to allow the OpenSSH server to listen on port 1255.
firewall-cmd
command:sudo firewall-cmd --add-port=1255/tcp --permanent sudo firewall-cmd --reload
This will update the firewall rules to allow incoming connections on port 1255.
After completing these steps, the OpenSSH server should be listening on port 1255 and allowing incoming connections on that port. You can use the ss -lnp
command to verify that the OpenSSH server is listening on the correct port.
Note: These steps assume that you are using the default SELinux policy and firewall configuration on your system. If you have modified these settings, you may need to adjust the steps accordingly.