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.
ssh target
, you're going to typessh gateway
and your osx config file needs to have an entry forgateway
, nottarget
.