I must set up a ssh tunnel on a Mac OS X, to access to some servers.

So I did on the Mac OS :

  1. ssh -D 9999 user@host
  2. In the preference system, I had a proxy SOCKS (localhost:9999)
  3. In the /etc/hosts I had the ips for the servers
  4. the Mac Os can now access to the servers with it browser, for example.

But, with a terminal, it can't reach the servers. I Guess it's because the terminal do not use the "preference system".

So what does I have to do to get this tunnel working with the terminal ?


It depends on the specific command-line program you're using. For example, curl has a bunch of options for using different versions of the socks proxy protocol:

curl -s --socks5 localhost:9999 http://myip.is/ | grep javascript:doCopy

(this should show the public IP of the computer you ssh'ed into.)


Not sure if you have a typo - looks like you have three 9's in your ssh command and four 9's in your socks

What program are you using from the terminal, this program would most likely have to be configured to use the local proxy.

  • it's a typo error. Well, all the program, for example curl doesn't reach the servers – pasta Nov 11 '11 at 14:34
  • Are you using the socks5 flag? --socks5 <host[:port]> Use the specified SOCKS5 proxy - but resolve the host name locally. If the port number is not specified, it is assumed at port 1080. This option overrides any previous use of -x, --proxy, as they are mutually exclusive. – ckliborn Nov 11 '11 at 15:25

Only few programs can use SOCKS Proxies natively. Some programs can be forced through the Proxy, though, with tools like tsocks.

Nice alternative: Create tunnels listening on 127.0.0.X, X starting at 2 and being increased for every server, and edit hosts accordingly.

ssh -L127.0.0.2:80:server:80 user@proxy

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.