Anti-nuisance lawsuit warning: The purpose of these notes is to remind me, Zoegond, of stuff or to help me work stuff out. They may contain mistakes.

Quick

  • ($a, $b....) = unpack("A2A7...", $packed)
  • push( array, list )

Monday, February 27, 2012

ssh chain tunnelling

Suppose you have

- a local PC at which you are sitting
- a gateway server which allows ssh connections from outside the firewall
- a remote PC of your own, also behind the firewall, also running sshd
- a target server which your remote PC can connect to, but the gateway can't

and you want to connect from the local PC - which is outside the firewall - to a port (say 1433 for SQL Server) on the target server.

Firstly set up a tunnel to your remote PC

plink -v -N dugeen@gateway.dugeenswork.co.uk -L 127.0.0.2:3381:remotepc.dugeenswork.co.uk:22

And then tunnel through the first tunnel onto the target server

plink -N -v -P 3381 dugeen@127.0.0.2 -L 127.0.0.2:3382:target.dugeenswork.co.uk:1433

(NB that -P 3381 dugeen@127.0.0.2 is saying 'connect to ssh on 127.0.0.2:3381 as dugeen')

Port 3382 on your local PC (127.0.0.2:3382) is now connected to port 1433 on target.

NB that you run both commands on your local PC, you don't ssh to remotepc to issue the second command.

3381 and 3382 are arbitrary choices, you can use any free ports on your local PC. And 1433 would be replaced by whatever port you were interested in on target.

Followers

Blog Archive