Monday, October 9, 2017

Socks Proxy Setup


I can never remember how to set up a Socks proxy to my Digital Ocean Droplet, so here is a simple little how-to guide.

Using a secure proxy server to somewhere else in the wild wild world, to get through a local insecurity suddenly got added urgency, since the WiFi WPA2 protocol is now officially broken.

Using a secure proxy in this way, will prevent local script kiddies from looking over your shoulder on a WiFi connection.

The most fun you can have with your socks on!

Note that the cheapest Digital Ocean Linux or BSD virtual server costs only $5 per month and that is all you need.  You don't even need to change or install anything on it, since it comes with sshd running by default.  So, just sign up for one, start using socks over ssh and relax.

On the laptop:
Add nameserver to the top of /etc/resolv.conf

Start the socks proxy:
# killall ssh
# ssh -fND 2222 -p 22 root@w.x.y.z

Open Menu
Preferences, Advanced, Network, Settings:
Socks host: localhost, port 2222
Socks 5
Use Remote DNS

Open Skype.
Enter your Skype credentials and Sign in.
In the Menu Bar click Tools and then Options…
Advanced, Connection.
Automatic proxy detection: SOCKS 5.
Host: localhost
Port: 2222.
Uncheck Enable proxy authentication.
Restart Skype and Sign in again.

This script sort of works:
#! /bin/bash
sed -i -e 's/nameserver/nameserver\nnameserver/' /etc/resolv.conf
killall ssh
ssh -fND 2222 -p 22 root@w.x.y.z


On a Macintosh, as soon as you enable the Socks proxy server in the System Settings, *everything* will go through it - Email, Safari, Firefox, Skype...  This is both convenient and annoying, since from then on, you always have to run the proxy.

Rather than wearing out your mouse with endless clicking, the Mac proxy settings can be changed using a couple scripts and the networksetup utility.

Script sockson:
#! /bin/bash
echo Enable the Socks Proxy
killall ssh
ssh -D 2222 -f -C -N root@droplet
networksetup -setsocksfirewallproxystate "Wi-Fi" on

Script socksoff:
#! /bin/bash
echo Disable the Socks Proxy
killall ssh
networksetup -setsocksfirewallproxystate "Wi-Fi" off

Note that on a Mac the application 'firewall' in System Preferences, Security and Privacy, is best turned off.  Otherwise you may have trouble with one way connections

On a Mac, you can see what is going on - who is talking to who - with the utility nettop.

La voila!


No comments:

Post a Comment

On topic comments are welcome. Junk will be deleted.