2

I have a computer A, a server B (Azure VM) and a second computer C. I want to connect from A to C through the server B.

Setup:

A: ssh -i location_of_private_key -L 12000:public_IP_of_B:20000 user@serverB

C: ssh -i location_of_private_key -R 20000:localhost:12000 user@serverB

Testing:

A: nc localhost 12000

C: nc -l 12000

But the first testing command (in A) fails, I can't establish connection to B on port 20000.

What am I missing ?

Bonjour123
  • 133
  • 4
  • Is there any service on public_IP_of_B on port 20000 listening? If yes - is it reachable from serverB? – Tomek Dec 19 '18 at 20:27

1 Answers1

4

You are making a couple of mistakes:

  • Port forwardings by default listen only on localhost so that's what you have to connect to in the first command.
  • You need to start the listener before you try to connect to it.

Fix those two mistakes and it should work.

kasperd
  • 30,455
  • 17
  • 76
  • 124
  • Whoo, I was 10000% sure I had also tried to start the listener first (this is quite logical ^^). But maybe I had another mistake somewhere else. Anyway, thanks a lot, this fixed my problem ! :) – Bonjour123 Dec 19 '18 at 20:51