malatesh malatesh - 8 days ago 5x
Linux Question

SSH set non default port

I am trying to change default port of SSH from 22 to 2292, Host: RHEL 7.1

I have tried:

1)vi /etc/ssh/sshd_config
#Port 22
Port 2292



ssh -p 2292
ssh: connect to host port 2292: No route to host

but ping to the host works

2 packets transmitted, 2 received, 0% packet loss, time 1000ms

Please help


It's possible that this new port 2292 is not open on your RHEL 7.1 host and the inbuilt firewall (also known as iptables) is declining the connectivity.

Check the current firewall rules:

$ sudo iptables -L

To open up a new port - port 2292 - in your case:

$ sudo firewall-cmd --zone=public --add-port=2292/tcp --permanent
$ sudo firewall-cmd --reload

Check the updated rules:

$ firewall-cmd --list-all

Let me know if it worked.