I have an established ssh tunnel (port 9876) that is running in the background and was established with this command:

/usr/bin/autossh -M 0 -o ServerAliveInterval 30 -o ServerAliveCountMax 3 -D 9876 user@example.com -i /path/to/keyfile -T -N -n

Let's say I cannot change anything about it. I can utilize the tunnel from applications like Firefox by specifying a socks5 proxy on localhost on port 9876.

My question is how can I utilize that existing tunnel from another bash shell?

I know of some specific tools allow using a local proxy in this way, such as curl:

curl -sS -x socks5:// icanhazip.com

However, I am interested in the general question of how to make any Internet connection from a bash shell utilize this existing ssh tunnel, without relying on a program to have that feature. Is it possible?


I think the tsocks tool might be what you are looking for.

  • I believe you are talking about: tsocks.sourceforge.net. It has not been updated in over 16 years. I'm not sure using it for a secure tunnel is a good idea...
    – MountainX
    Jun 3 '19 at 3:07

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.