I've been having trouble with one of my linux computers. I have a router and two linux boxes behind it. I want to access both of them from Internet with ssh.

I have set up port forwarding: port 2220 goes to machine A:22, port 2221 goes to machine B:22. I know the public IP of the router and can ping/connect to it either using the public IP or my set up DDNS service.

I can ssh from machine A to B through local net fine. I can ssh to machine A from Internet.

Here's the problem: I cannot ssh into machine B from Internet. The connection just times out.

When connecting I am using the -p flag to select the port (the connection Internet->A works fine)

Machine A: Ubuntu 16

Machine B: RaspberryPi 3 running Minibian headlessly. Doesn't seem to have iptables or ufw installed.

Any help greatly appreciated.

  • 2
    I'd try running tcpdump on machine B to see if any traffic is reaching it on port 22. If it's not, it's probably on the router side. If it is, it's most likely something related to local setup. – Marko Živanović Apr 3 '17 at 11:54
  • « Doesn't seem to have iptables [...] installed » Please confirm that by running iptables -nvL on the Pi as root. You should get three empty chains (INPUT, OUTPUT, FORWARD) all with a policy of ACCEPT. – roaima Apr 3 '17 at 12:20
  • 1
    If you telnet public_ip_of_router 2220 or nc -vvv public_ip_of_router 2220 from your remote client you'll get a one-line banner that starts SSH-2.0-OpenSSH.... You should also get something similar on port 2221. Please confirm whether you do or don't. If you don't, please report the precise error message or response you receive when connecting. – roaima Apr 3 '17 at 12:23
  • ISP may be blocking 2221 port. Try switching them, set 2221 for machine A and 2220 for machine B so we eliminate that possibility. – Luka Apr 3 '17 at 13:09
  • @MarkoŽivanović here are the outputs of the command sudo tcpdump 'port 22 and not host' -vv Pastebin, That is what I receive when I try to ssh into machine B fromInternet. I don't really understand what that means though. I cancelled the tcpdump after I did not receive anything for some minutes. – Roberts Gotlaufs Apr 3 '17 at 14:25

Your Answer

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

Browse other questions tagged or ask your own question.