Last active
April 30, 2017 13:12
-
-
Save lukaszkorecki/202eb8b49c02fc191d5266a757d805cf to your computer and use it in GitHub Desktop.
Fast and easy socks proxy setup on OSX: enables proxy, starts the proxy connection and cleans up after itself when its done
This file contains 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
#!/usr/bin/env bash | |
# Enable SOCKS tunnel for given interface, ssh to a remote machine | |
# and open a SOCKS proxy. | |
# When cancelled it will disable proxy settings for given interface | |
# Start with sudo socks.sh if you want it to modify all settings for you | |
# or just run socks.sh to be prompted on all settings changes | |
user= # ssh user | |
host= # ssh host | |
interface="Wi-Fi" # find with networksetup -listnetworkserviceorder | |
proxyPort=8080 # proxy port to use | |
log() { | |
logger -t SOX -s "$*" | |
osascript -e "display notification \"$*\" with title \"SOX\"" | |
} | |
log "Connecting to a proxy on $user@$host:$proxyPort and attaching to interface $interface" | |
networksetup -setsocksfirewallproxy "$interface" localhost $proxyPort | |
ssh -D $proxyPort -p 22 $user@$host -t 'while true ; do date;echo Proxying;sleep 30; done' | |
networksetup -setsocksfirewallproxystate "$interface" off | |
log "We done, cleaning up" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment