Created
May 29, 2013 17:54
-
-
Save jbott/5672278 to your computer and use it in GitHub Desktop.
Automatically create a ssh socks proxy and turn it on in network settings
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
#!/bin/sh | |
####################################### | |
#Remote settings | |
USER=USERNAME | |
HOST=HOSTNAME | |
PORT=22 | |
#Local settings | |
INAME=Wi-Fi | |
LPORT=8080 | |
####################################### | |
if [ "$(id -u)" != "0" ]; then | |
echo "This script must be run as root" 1>&2 | |
exit 1 | |
fi | |
echo "Starting proxy..." | |
ssh -ND $LPORT $USER@$HOST -p $PORT & < /dev/null | |
SSH_PID=$! | |
networksetup -setsocksfirewallproxystate $INAME on | |
echo "Started." | |
read -p "Press any key to close." | |
networksetup -setsocksfirewallproxystate $INAME off | |
kill $SSH_PID |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment