Step 1: create the connectivity file
standard ssh command, dropped into a shell script with the port forwarding flag added:
file:
socks.ssh
content:
#!/bin/bash
ssh -D 1080 username@myhomeserver.com
That's it, that simple ... so what did we just do? SSH -D is for dynamic application-level port forwarding. Its syntax is ssh -D ${port} ${remote host} This will allow you to drop a SOCKS proxy over an encrypted ssh tunnel, which leads us directly to ...
Step 2: SOCKS over SSH Tunnel
Now lets over ride the Mac security settings and skip all that silly administrative stuff ...
file:
socks.start
content:
#!/bin/bash
echo "Setting Socks Proxy to 'localhost 1080'"
networksetup -setsocksfirewallproxy "Wi-Fi" localhost 1080
echo "'Wi-Fi' Socks Proxy now pointing to 'localhost 1080'"
networksetup -setsocksfirewallproxy "Ethernet" localhost 1080
echo "'Ethernet' Socks Proxy now pointing to 'localhost 1080'"
This will point all of your outgoing data through your ssh tunnel - averting the firewall and security setup by your administrators
Now we need a way to stop/disable these settings:
file:
socks.stop
content:
#!/bin/bash
echo "Disabling Socks Proxy from 'localhost 1080'"
networksetup -setsocksfirewallproxystate "Wi-Fi" off
networksetup -setsocksfirewallproxystate "Ethernet" off
echo "'Wi-Fi' and 'Ethernet' Socks Proxy now set to 'off'"
Pretty simple ... you will need to set the files as executable: chmod +x socks.ssh socks.start socks.stop
No comments:
Post a Comment