Created
August 18, 2016 04:35
-
-
Save joshjordan/6a5d5c693cb44a5c56c6568794473dc2 to your computer and use it in GitHub Desktop.
Simple script to connect to a dynamic proxy via SSH and connect your local OS X wifi to it via SOCKS. Disconnects on CTRL+C
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Set PROXY_HOST to the SSH proxy hostname (optionally, include a username) | |
# Override PROXY_PORT if necessary | |
sudo -s <<EOF | |
trap clear_proxy INT | |
function clear_proxy() { | |
echo "Disconnecting proxy..." | |
networksetup -setsocksfirewallproxystate "Wi-Fi" off | |
} | |
echo "Setting proxy to localhost:${PROXY_PORT:=6000}" | |
networksetup -setsocksfirewallproxy "Wi-Fi" localhost $PROXY_PORT | |
echo "Connecting to $PROXY_HOST dynamic proxy via SSH" | |
ssh -D $PROXY_PORT -N $PROXY_HOST | |
EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment