Super simple internet proxy script for Ubuntu users
Posted in Linux, Security. Updated .

Whenever I want to securely proxy my web traffic through my VPS I just run this script in the terminal. There’s nothing terribly complicated about it – just a simple chain of commands to create a SOCKS proxy through an SSH tunnel. As it is targeted specifically to my current operating system of choice, Ubuntu (14.04), it might not work on other Linux flavors. But since Ubuntu is an ever-popular OS, I thought I’d post this snippet for posterity.

Just create a script file called and copy the following code:

#!/usr/bin/env bash
# Create a SOCKS proxy on a remote server through an SSH tunnel


set -e 

function clear_proxy_settings() 
    echo 'Clearing system proxy settings'
    gsettings set org.gnome.system.proxy mode 'none'

trap clear_proxy_settings EXIT # catch exit signals

echo 'Setting system proxy settings to '${HOST}':'${PORT}
gsettings set org.gnome.system.proxy.socks host $HOST
gsettings set org.gnome.system.proxy.socks port $PORT
gsettings set org.gnome.system.proxy mode 'manual'

echo 'Opening SSH tunnel'

trap - EXIT # reset the trap

clear_proxy_settings # call cleanup manually

exit 0

Make sure to edit the line REMOTE='myusername@myremotehost' to suit your specific case. And, of course, ensure that the script is executable: chmod +x Then, to run:


In your browser, go to to check that your exposed IP is indeed that of your remote server. If all is working correctly, you should now be securely tunneling your traffic through your remote server!

The script will run indefinitely until you terminate it with CTRL-C.