2

My home PC is behind NAT but my router has static ip address. My work PC uses 3G stick for Internet (So I guess it is like being behind NAT).

I would like to create a reverse SSH-tunnel to connect to my work PC. Following lots of manuals I create a tunnel on my work PC:

ssh -R 33333:localhost:22 homeuser@135.142.205.131

Where 135.142.205.131 is my router's static IP address. When trying to connect to work from home I isssue:

ssh -p 33333 localhost

But I get "connection refused". I think I need to configure some port forwarding because I think I need to somehow make ssh let me connect some local port to my router's 33333 port to make the tunnel work. How do I do it?

Output at my work PC:

netstat -nap --inet --tcp

Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:56789           0.0.0.0:*               LISTEN      1402/klient
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      -
tcp        0      0 10.0.85.14:56731        104.20.90.217:443       ESTABLISHED 1402/klient
tcp        0      1 10.0.85.14:52501        135.142.205.131:22      SYN_SENT    2366/ssh
tcp        0      0 10.0.85.14:56789        52.49.10.125:53633      ESTABLISHED 1402/klient
tcp        0      0 10.0.85.14:47118        104.20.89.217:443       ESTABLISHED 1402/klient

Output of netstat - output at my works PC:

Active Internet connections (w/o servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State
tcp        0      0 10.0.85.14:56731        104.20.90.217:https     ESTABLISHED
tcp        0      1 10.0.85.14:52501        135.142.205.131:ssh     SYN_SENT
tcp        0      0 10.0.85.14:56789        ec2-52-49-10-125.:53633 ESTABLISHED
tcp        0      0 10.0.85.14:47118        104.20.89.217:https     ESTABLISHED
7
  • If your router forwards port 33333 to the pc-port 22, you should be able to connect directly via ssh -p 3333 homeuser@.... – gerhard d. Apr 18 '16 at 11:41
  • I'm not quite understanding you. I though I forward my home PC's port 33333 to my work's 22. So why should I connect to port 22 on home's PC? – rightaway717 Apr 18 '16 at 11:43
  • Sorry, i did misunderstand, see my edited comment above – gerhard d. Apr 18 '16 at 11:44
  • @gerhardd. why do I need "homeuser@..." ? "homeuser" is me on my home's PC, where I try to connect to work, do I need it? Did you mean homeuser@localhost? – rightaway717 Apr 18 '16 at 11:46
  • Ah, sorry2. You may give me a downvote for not reading tightly.. :( The reverse tunnel seems to be okay. You may verify this with "netstat -nap --inet --tcp", and look at the open connections at your work pc. As a second step, you need to make shure the ssh-daemon is listening on the work pc at localhost:22. This is also visible in the netstat - output. Please post it here, so we may look at it. – gerhard d. Apr 18 '16 at 11:52
1

This line:

 tcp 0 1 10.0.85.14:52501 135.142.205.131:22 SYN_SENT 2366/ssh

tells us, that the ssh-connection from the work pc to the home-pc has not been completed. So either a) the port forwarding from the router to the home-pc does not work, or b) the ssh-d on the home pc is not listening to the (correct) address

1
  • Ssh connection didn't really complete, as port forwarding was not correct on router. For simplicity I created 22 to 22 port forwarding on router as @gerhard suggested and it did work. Thank you @gerhard! – rightaway717 Apr 18 '16 at 13:20

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.