How do I set up two hop ssh tunneling
Posted on 2011-10-14
I have a gateway system which is connected by vpn to a remote server. I can ssh (or vnc) to the gateway from my host system and then ssh (or vnc) to the remote. I would like to do this in one step, by creating a tunnel from the host system to the remote via the gateway.
I can create a local tunnel on the gateway system using ssh:
[host] $ ssh gateway
eager@gateway's password: ********
[gateway] $ ssh -N -L 1234:remote:22 -f remote
eager@remote's password: *******
[gateway] $ ssh localhost -p 1234
eager@localhost's password: ******* [password for remote]
If I try to connect to the gateway port 1234 from the host system, it fails:
[host] $ ssh gateway -p 1234
ssh: connect to host gateway port 1234: Connection refused
Is there a way to set up a two hop tunnel:
host:1234 ==> gateway:1234 ==> remote:22
Can this be done with SSH? Or VPN?