Transparent Connection Proxies Through Ssh

Have you ever ssh'ed into a remote server and wondered if you could run a program using the connection from that remote server in a transparent and easy way?

Well, you can and it's quite simple. Here's the recipe for Linux.

1. Install tsocks using your Linux distribution package manager (preferably) or compiling from source.

2. Add a file ~/.tsocksrc with this content:

server =
server_type = 5
server_port = 9999

3. add this to your environment variables:


4. ssh'd into the remote server by typing:

ssh -D 9999 user@server

5. launch the application using tsocks. For example, if you want to run Firefox using the remote server connection, type:

tsocks firefox

There you go. The program will run using the connection from the remote server (where you have ssh'ed) in a complete transparent way, no matter which ports the program uses. An alternative way is to run the programs with this environment variable set:


That would use the tsocks library always, even if you don't run the program with tsocks.

If tsocks is not available you still can do this if the application can be configured to use a SOCKS5 server (localhost:9999 in this case). For example, in Firefox you would have to go to: Preferences - Advanced - Network - Connect - Settings, and enter SOCKS Host: localhost, Port: 9999.