I have three machines:
- I have physical access to
localhost
- I want to ssh into
host1
. However, it is behind carrier-grade NAT, so I can't ssh directly to it fromlocalhost
relayhost
is set up to help me connect fromlocalhost
tohost1
I want to ssh from each localhost
and host1
to relayhost
, then have relayhost
relay my ssh connection from localhost
to host1
.
This answer suggests I can create a tunnel on relayhost
using ssh -L
if I know the URI or IP address of host1
. However, I don't know that because of the carrier grade NAT. So I can imagine a process to relay it like this:
- On
host1
,ssh user@relayhost
relayhost
is watching for this connection and when it sees it says "I'm going to create a tunnel from my port 9999 to this connection"- On
localhost
,ssh 9999:relayhost
Is this the right way to go about this? How do I do step 2?
localhost
andhost1
are behind NAT, he can't circumvent it... – Marek Rost Nov 29 '17 at 17:17machineB$SSH -R 1234:127.0.0.1:1000 hostxIP
Thenhost1$SSH hostx:1234
And that should connect indirectly, to machineB on port 1000. – barlop Nov 29 '17 at 17:18