1

I am trying to set up an ssh tunnel on my Mac OSX ('osx') to a server ('target') via an interim host ('gateway'). This tunnel needs to have a local (osx) port forward so that my Windows XP VM ('vm') can tunnel traffic through it (using proxifier). So ultimately it will be:

vm -> osx -> gateway -> target

I can achieve this successfully using this command line on osx:

ssh -p 7002 -L 7777:localhost:6677 -t [email protected] sh ./tunnel.sh target.tld;;

where tunnel.sh is a script on the remote gateway with the following:

#!/bin/bash
/usr/bin/ssh -i ~manachi/.ssh/my.id -p 7002 -D 6677 manachi@${1}

But I've been trying to set this up in my ~/.ssh/config on my osx (so that i can just type 'ssh target') but am not having much luck. My vm seems to be unable to tunnel via the osx tunnel. Here is the config entry:

host target
HostName target.tld
Port 7002
User manachi
LocalForward 0:7777 localhost:6677
ProxyCommand ssh gateway nc %h %p

I'm not sure if I'm going about this all wrong. I'm not sure if the LocalForward is set up correctly, or if I can use 'nc' in ProxyCommand like that as a replacement for the remote 'ssh' command in the first solution, but any help or tips would be appreciated.

1
  • You had it right in your command lines. You're not going to type ssh target, you're going to type ssh gateway and your osx config file needs to have an entry for gateway, not target.
    – ckhan
    Oct 26, 2012 at 3:03

1 Answer 1

1

After much tweaking and experimenting and logging, I managed to get this tunnel working end-to-end by changing the line:

LocalForward 0:7777 localhost:6677

to

DynamicForward 0:7777

So final config entry looks like:

host target
HostName target.tld
Port 7002
User manachi
DynamicForward 0:7777
ProxyCommand ssh gateway nc %h %p

Now I can just type

ssh target

And then on my XP Virtual Machine I can point my Proxifier to my macosxhost:7777 and all working perfectly!

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .