SSH works only on the standard port

I can connect to my remote server only if I use the standard 22 port. When I change the Port (to 40004 for e.g.) in /etc/ssh/sshd_config I get an error:

ssh: connect to host 123.45.67.890 port 40004: Connection refused

SSH and SSHD services were reloaded. Output of ufw status:

Status: active
To                         Action      From
--                         ------      ----
22                         ALLOW       Anywhere
40004/tcp                  ALLOW       Anywhere
22 (v6)                    ALLOW       Anywhere (v6)
40004/tcp (v6)             ALLOW       Anywhere (v6)

Output of netstat -lnp | grep sshd:

tcp        0      0 0.0.0.0:40004           0.0.0.0:*               LISTEN    1398/sshd
tcp6       0      0 :::40004                :::*                    LISTEN    1398/sshd

OS: Ubuntu 15.04 x32 (in early versions I have the same problem).

What the problem?

Answer

… as I mention in my comment:

doing ssh -v -p 40004 0 from host itself, will provide that you are able to connect to sshd on non-standard port and rest would fall to networking (assuming your part is okay, then most likely your isp).

Attribution
Source : Link , Question Author : 0x1337 , Answer Author : alexus

Leave a Comment