Search code examples
linuxunixsshadminunix-socket

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

2)reboot

Error

ssh -p 2292 [email protected]
ssh: connect to host lrmi079.pll.domin.com port 2292: No route to host

but ping to the host works

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

Please help


Solution

  • 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.