Two ways of chaining:
Connect from home to gateway, forwarding localhost:1521
on home via gateway to localhost:PORT
.
Connect from gateway to desktop, forwarding localhost:PORT
on gateway via desktop to dbserver:1521
.
home$ ssh -ftL 1521:localhost:PORT gateway ssh -NL PORT:dbserver:1521 desktop
PORT can be 1521 or any other port.
Connect from home to gateway, forwarding localhost:PORT
on home via gateway to desktop:22
.
Connect from home to desktop using the established tunnel via gateway, forwarding localhost:1521
on home via desktop to dbserver:1521
.
home$ ssh -fNL PORT:desktop:22 gateway
home$ ssh -fNL 1521:dbserver:1521 -o "HostkeyAlias=desktop" -P PORT localhost
DB connection can be made now
(The -fN
options tell SSH to connect, establish tunnels, then continue running in background.)
The second method is more useful, since it allows you to reach desktop directly from home (using the running tunnel) for all kinds of connections.
Thanks for posting that answer, I now realise I'm actually up against an altogether bigger problem as the dbserver just listens on that port, it immediately opens another port for communication. Think this is trickier than I can handle... – Alasdair – 2012-02-08T16:56:03.173