0

I have OpenSSH Server installed on a Ubuntu (Server) 14.04 machine. I can connect over my local network but cannot across the Internet. I have port forwarding set up on the router.

I have tried:

  1. Changing from port 22 to another (random) port to make sure it’s not because my ISP is blocking port 22
  2. Temporarily disabling the firewall for testing. Neither of these resolved the problem.

Any ideas why I can’t connect? The error is:

connect to address port : Connection refused

d

Here is the netstat output:

netstat -apn | grep: 42530

(No info could be read for "-p": geteuid()=1000 but you should be root.)
tcp        0      0 0.0.0.0:42530           0.0.0.0:*               LISTEN      -               
tcp        0    116 192.168.2.23:42530      192.168.2.11:58944      ESTABLISHED -               
tcp6       0      0 :::42530                :::*                    LISTEN      -             
  • look into what the firewall for ubuntu is. maybe it blocks incoming by default. – barlop Feb 16 '15 at 1:51
  • @barlop I tried disabling the firewall but to no avail – JonaGik Feb 16 '15 at 1:57
  • worth trying with nc (nc -l -p 22 or nc -l 22 , whatever the syntax), and doing an online port scan to see if that works. Also, see if the server is bound to 0.0.0.0 or 127.0.0.1 or just the LAN like 192.168 – barlop Feb 16 '15 at 2:00
  • @barlop How do I see what it is bound to (and what does it mean to be bound)? Thanks – JonaGik Feb 16 '15 at 2:04
  • The netstat command, with the right switches.. netstat -apn | grep :22 then see if it says 0 0.0.0.0:22 it means it is bound in such a way as to allow any IP to connect. But if it says 127.0.0.1:22 or 192.168.0.1:22 then (in the case of 127.0.0.1:22) it is bound such that nobody other than localhost can connect or (in the case of 192.168.0.1:22) so that only other comps on the LAN can connect – barlop Feb 16 '15 at 2:10
0

I would try a different approach - I would do 2 things - The first would be to execute another instance of SSH on an alternative port (don't forget to port forward it in the router) - with - as root - a command like

/usr/sbin/sshd -p 2222 -d

This will launch another instance of SSHD on port 2222 with debugging on - so it won't turn into the background. I'd then try connecting to it remotely and seeing what happened. (On the remote side I'd also type something like

ssh -v ip.addr

So that I can see what is happening in the negotiation.

If I don't see any talking between the client and server the next step would be to use tcpdump on the server to see if traffic is reaching and/or leaving the server. Something like:

/usr/sbin/tcpdump -n -i eth0 port 2222

Which could test if port forwarding is working - at least if traffic is being forwarded through the router and going back to the router.

0

The problem was that the router is apparently blocking connections to its public IP originating from within the network. If I attempt to connect from outside the local network, it accepts the connections. Strange...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.