Skip to content

Instantly share code, notes, and snippets.

@jtorvald
Last active February 8, 2019 14:44
Show Gist options
  • Save jtorvald/4caecaaa5fe78137976e444f6eea8e19 to your computer and use it in GitHub Desktop.
Save jtorvald/4caecaaa5fe78137976e444f6eea8e19 to your computer and use it in GitHub Desktop.
Setup socks proxy through ssh and change proxy settings on Mac OSX
# connect to ssh host on a specific port and open the local port (8123 in this case)
ssh -D 8123 -f -C -q -N user@example.com -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