Skip to content

Instantly share code, notes, and snippets.

@marschhuynh
Last active March 15, 2020 09:55
Show Gist options
  • Save marschhuynh/8f0f49801e95dfdaa22d140c3e9b900e to your computer and use it in GitHub Desktop.
Save marschhuynh/8f0f49801e95dfdaa22d140c3e9b900e to your computer and use it in GitHub Desktop.
Sock proxy
#! /bin/sh
SERVER=gg-sing
HOST=localhost
PORT=8123
SOCK_ID=$(date +%s)
ssh -CNM -f -q -D 8123 -S /tmp/proxy-${SOCK_ID}.sock ${SERVER}
sudo networksetup -setsocksfirewallproxy "Wi-Fi" localhost 8123
COMMAND=""
while [ "$COMMAND" != "q" ];
do
clear
echo "=========== Mini proxy tools ==========="
echo "\t Press 'q' to quit."
read COMMAND
done
sudo networksetup -setsocksfirewallproxystate "Wi-Fi" off
ssh -S /tmp/proxy-${SOCK_ID}.sock -O exit ${SERVER}
# -D: Tells SSH that we want a SOCKS tunnel on the specified port number (you can choose a number between 1025-65536)
# -f: Forks the process to the background
# -C: Compresses the data before sending it
# -q: Uses quiet mode
# -N: Tells SSH that no command will be sent once the tunnel is up
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment