Mar 25 2015

How to Change SSH Port When Selinux is Enable on Oracle Linux 7

Category: Linux & Unix,System SecurityFatih Acar @ 15:47

SSH service runs on 22 port number. You can change this port number for security. If you use Oracle Linux 7, Centos 7 or Red Hat Linux 7 versions, you can change port number with below operations. If selinux is enabled, you have to add new port number to selinux configuration because of the fact that selinux allows only 22 port number for ssh connections.

Step 1 : Change Port Number

[root #] vi /etc/ssh/sshd_config
Port 2290

Save and Exit

Step 2 : Change Selinux Configuration

To change:
[root #] semanage port -a -t ssh_port_t -p tcp 2290
To list:
[root #] semanage port -l | grep ssh

Step 3 : Add New Port to Firewall

To Add:
[root #] firewall-cmd –permanent –zone=public –add-port=2290/tcp
To Activate
[root #] firewall-cmd –reload

Step 4 : Restart SSHD Service to Activate New SSH Confiuration

[root #] systemctl restart sshd.service

Step 5 : Show Running SSH Port

[root #] ss -tnlp | grep ssh

15,323 total views, 5 views today

facebook comments:

Leave a Reply

Time limit is exhausted. Please reload CAPTCHA.