Steps to Change SSH Port in Red Hat Enterprise Linux
Earlier, we’ve had a look at the Steps to Change SSH Port of a Linux Server from the default port 22 to one thing of your preference. The steps described in this should are useful, however it there weren’t due the actual fact that you simply have RHEL 6 installed on the server, then you almost certainly would have encountered an error stating the denial of permissions.
This is as a result of the Security Enhanced Linux or SELinux is enabled over your server. This is often essentially a default feature that comes equipped with Red Hat Enterprise Linux that is answerable for blocking every port that provides access to SSH, only the port 22 is provide this capability by default.
If you would like to use the other port, few changes within the settings ar needed. the subsequent steps would assist you change your SSH Port in SELinux
Step 1 : Login as Root
Step 2: To check the settings of the port that you currently Run semanage. As root, type:
semanage port -l | grep ssh
The similar command as shown below should be able to see:
ssh_port_t tcp 22
Step 3: Here, you have to proceed with adding your required port. Use the below command to try to do so:
semanage port -a -t ssh_port_t -p tcp 1234
Note : You have to just make a small change by replacing 1234 with the port number of your preference
Step 4 : By using the following command run a quick check to ensure that the port has been added to acceptable port list:
semanage port -l | grep ssh
You should be able to see that the desired port has been added by execution of the command :
ssh_port_t tcp 1234,22
Step 5 : For the changes to apply restart OpenSSH using the following command :
/sbin/service sshd restart
This will permit you to access SSH via. your required port. You furthermore should make sure that the SSH is well configured and also the port is enabled within the firewall settings as well.
You may contact our support department for any help with this. You can also raise a ticket via. helpdesk, drop an email to [email protected] or reach via. Live Chat. we provide around the clock web hosting services and take privilege in serving to you get the problem resolved at the earliest.