Last active
February 8, 2019 14:44
-
-
Save jtorvald/4caecaaa5fe78137976e444f6eea8e19 to your computer and use it in GitHub Desktop.
Setup socks proxy through ssh and change proxy settings on Mac OSX
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
# connect to ssh host on a specific port and open the local port (8123 in this case) | |
ssh -D 8123 -f -C -q -N [email protected] -p 1022 | |
# setup the socks proxy for the Wi-Fi adapter to connect to port 8123 | |
networksetup -setsocksfirewallproxy "Wi-Fi" localhost 8123 | |
# wait till user presses a key to revert changes | |
read -p "Setup. Please connect. Press enter key to disconnect" | |
# turn off socks proxy | |
networksetup -setsocksfirewallproxystate "Wi-Fi" off | |
# kill the ssh command | |
kill -15 $(ps aux | grep "[s]sh -D" | awk '{ print $2}') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment