Connecting via two tunnel hops?

cgrozev's profile image cgrozev posted 9 years ago in General Permalink
Hi. Any idea if it is possible to connect via two tunnels (I need to first access a gateway via SSH, where - via SSH - I login to our actual server). Maybe via start-up script? Or using a batch version of Putty?

thanks for any advice!

Regards

Christo
[expired user #9353]'s profile image [expired user #9353] posted 8 years ago Permalink
Hi,

You basically have three possibilities:

Tunnel from
localhost
to
host1
:

ssh -L 9999:host2:1234 -N host1

As noted above, the connection from
host1
to
host2
will not be secured.

Tunnel from
localhost
to
host1
and from
host1
to
host2
:

ssh -L 9999:localhost:9999 host1 ssh -L 9999:localhost:1234 -N host2

This will open a tunnel from localhost to host1 and another tunnel from
host1
to
host2
. However the
port 9999
to
host2:1234
can be used by anyone on
host1
. This may or may not be a problem.

Tunnel from
localhost
to
host1
and from
localhost
to
host2
:

ssh -L 9998:host2:22 -N host1
ssh -L 9999:localhost:1234 -N -p 9998 localhost

This will open a tunnel from
localhost
to
host1
through which the SSH service on
host2
can be used. Then a second tunnel is opened from
localhost
to
host2
through the first tunnel.

Please login to leave a reply, or register at first.