Ssh tunnel not working with terminal

mac-osxssh-tunnel

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 ?

Best Answer

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.)