SSH proxy

From Urandom
Revision as of 11:27, 2 January 2013 by Martivo (talk | contribs) (Created page with "== Creating the ssh tunnel == * I use this script to maintain a ssh tunnel. I use it on public WIFI or at work, this way nobody can see what you are doing on the net, because al…")

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Creating the ssh tunnel

* I use this script to maintain a ssh tunnel. I use it on public WIFI or at work, this way nobody can see what you are doing on the net, because all the traffic is directed throught the SSH tunnel to your server
#!/bin/sh
while [ 0 -le 1 ]
do
netstat -l --numeric | grep 8080 | grep -q 127 || ssh -f -C -N -D8080 mardicas.dyndns.org &
sleep 5
done
* Create endless loop that sleeps every 5 seconds.
* Check weather the port is listening on localhost
* If not start the ssh tunnel

Using with tsocks

* Install tsocks and configure /etc/tsocks.conf
local = 192.168.0.0/255.255.0.0
local = 10.0.0.0/255.0.0.0
local = 127.0.0.1

server = 127.0.0.1
# Server type defaults to 4 so we need to specify it as 5 for this one
server_type = 5
# The port defaults to 1080 but I've stated it here for clarity 
server_port = 8080

* in local define the IPs that you dont want to go through a proxy, usually your local network
* server must be your localhost, because the tunnel listens on your machine not the ssh server.

Now simply run tsocks firefox to use the proxy, you can of course make the program use proxyes themselves without tsocks but I found it to be convenient.