TWiki Announcment

Hi there, welcome to my personal Wiki. I named it TWiki only because T is a special letter for me and my family. It is not powered by TWiki anyway! Have fun!
Computers‎ > ‎Tools‎ > ‎

SSH Tunnel

Browser    <== secure tunnel ==>    ssh server    <===>    twitter.com

Mac OS X
Terminal.app, iTerm2 or iSSH.app (GUI, so far iSSH doesn't work under Snow Leopard)

Linux
Terminal, CLI or PuTTY (plink is better choice).

ssh -qTfnN -D 1080 hostname

All the added options are for a ssh session that’s used for tunneling.
-q be very quiet, we are acting only as a tunnel.
-T Do not allocate a pseudo tty, we are only acting a tunnel.
-f move the ssh process to background, as we don’t want to interact with this ssh session directly.
-N Do not execute remote command.
-n redirect standard input to /dev/null.
-D Dynamic socks based port forwarding
In addition on a slow line you can gain performance by enabling compression with the -C option.

Or we can use plink in putty-tools, here is a simple sample which shares the tunnel with all other hosts in the LAN.

Linux/Mac OS X
plink -C -A -N user@ssh_host  -D 0.0.0.0:port

Windows
plink.exe -C -A -N user@ssh_host  -D 0.0.0.0:port

It is the same as ticking SSH - Tunnels - Local ports accept connections from other hosts. Others in the same LAN will be able to use this tunnel as well. (Ticking this option will cause connection dropped due to unknown reasons.)

Note: -D 0.0.0.0 means to bind with any IP address so that other hosts in the same LAN will be able to use the tunnel.

How to surf the Internet via the tunnel (socks5 proxy)?

Firefox 7.0^ with Proxy Selector
Multiproxy Swith add-on
Note: set network.proxy.socks_remote_dns to true, use remote socks5 proxy to lookup DNS to avoid DNS pollution (GFW).

Chrome
pass the parameter when launching chrome, create a launcher or shortcut
Linux in Terminal
google-chrome --proxy-server=socks5://localhost:port
Mac OS X (doesn't work as expected...)
/Application/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --proxy-server=socks5://host:port
Windows in Command Line Prompt
%userprofile%\AppData\Local\Google\Chrome\Application\chrome.exe --proxy-server=socks5://localhost:port
Otherwise, use Proxy Switchy! extension to switch proxy settings.