Created
November 14, 2012 21:18
-
-
Save frank-who/4074899 to your computer and use it in GitHub Desktop.
Configure proxies in OSX and open an SSH tunnel
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
# Usage: bash ergo-proxy.sh <on off> | |
# Hitting ctrl-c while tunneled will exit the tunnel and turn the proxies off | |
STATE=$1 | |
# Get a list of network services: networksetup -listallnetworkservices | |
NETWORKSERVICE=Wi-Fi | |
# Local port | |
PORT=3128 | |
# Remote host | |
HOST=localhost | |
# Remote host port | |
HOST_PORT=8888 | |
# SSH connection string | |
CONNECTION="$HOME/.ssh/kp-xxx.pem [email protected]" | |
######################################################################## | |
sudo echo 'Sudo Up!' | |
proxy_on() { | |
echo 'Proxy On' | |
sudo networksetup -setwebproxy $NETWORKSERVICE $HOST $PORT | |
sudo networksetup -setsecurewebproxy $NETWORKSERVICE $HOST $PORT | |
ssh -L $PORT:$HOST:$HOST_PORT -N -i $CONNECTION | |
} | |
proxy_off() { | |
echo 'Proxy Off' | |
sudo networksetup -setwebproxystate $NETWORKSERVICE off | |
sudo networksetup -setsecurewebproxystate $NETWORKSERVICE off | |
} | |
control_c() { | |
echo '* Exiting' | |
proxy_off | |
exit $? | |
} | |
trap control_c INT | |
if [[ $STATE = 'on' || $STATE = '' ]]; then | |
proxy_on | |
elif [[ $STATE = 'off' ]]; then | |
proxy_off | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi, I read your article about set proxy server on aws ec2. However, I followed your article step by step. It still can't establish proxy server.
After this step :
ssh -L 3128:localhost:8888 -N -i ~/.ssh/kp-ergo-proxy.pem [email protected]
Should I see anything on my terminal ?