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 [email protected] -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?

1 Answer 1


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
    Commented Jun 3, 2019 at 3:07

You must log in to answer this question.

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