How to setup an SSH tunnel to browse the web securely
I often have the need to encrypt my traffic when using a public Internet wifi, like at a university or a coffee shop. After scouring the web, I tried a few different tunnels, but this one really worked.
This tutorial is aimed at people using OS X on a Mac, but could easily work for any other operating system.
ssh -D 8080 -f -C -q -N username@serverIP
If you have a non-standard SSH port, just add -p to the end of the command.
First, I setup this command as a /usr/bin command so I don’t have to remember it.
sudo nano -w /usr/bin/createtunnel
sudo chmod +x /usr/bin/createtunnel
This will allow you to just enter “createtunnel” at the command line on your computer and it will start the process.
After you run the command it will prompt you for your SSH password so you can login to your server. This is the first part of the process.
The second part is ensuring that your wifi device is using the proxy port that you just setup.
Next, go to your device and then go to Proxies. Then select SOCKS Proxy and enter the 8080 port which is part of the command above. You can adjust this port to be whatever you want it to be, I just use 8080 for simplicity.
After you click OK, your connection will now be tunneling your traffic through your encrypted SSH connection.
If you have any comments or suggestions, please let me know in the comments below.