Created
November 18, 2017 17:53
-
-
Save NFarrington/50e2e98144cce3f1d0b5aecffd9e64bb to your computer and use it in GitHub Desktop.
SSH SOCKS Proxy Command - MacOS
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 | |
# MacOS bash script to enable/disable an SSH SOCKS proxy on port 1080 | |
# | |
# Usage: ./sshsocks <hostname> | |
# | |
set -e | |
disable_proxy() | |
{ | |
echo "Disabling proxy..." | |
sudo networksetup -setsocksfirewallproxystate Wi-Fi off | |
echo "Proxy disabled." | |
} | |
trap disable_proxy EXIT | |
if [ -z "$1" ]; then | |
echo "Usage: ./sshsocks <hostname>" | |
exit | |
fi | |
sudo networksetup -setsocksfirewallproxy Wi-Fi 127.0.0.1 1080 | |
sudo networksetup -setsocksfirewallproxystate Wi-Fi on | |
echo "*******************************************************" | |
echo "*** SOCKS proxy enabled, establishing connection... ***" | |
echo "*******************************************************" | |
ssh -ND 1080 $1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment