Skip to content

Instantly share code, notes, and snippets.

@etaf
Created November 7, 2018 06:47
Show Gist options
  • Save etaf/2af2fd4f9f8e6e63eab94d6e096c526b to your computer and use it in GitHub Desktop.
Save etaf/2af2fd4f9f8e6e63eab94d6e096c526b to your computer and use it in GitHub Desktop.
proxy via ssh
# server: ss and polipo installed.
# polipo_port:8123, polipo config proxy type as socks5, and set corresponding ss_port
# then ssh to the machine which need proxy from server. assume your ss_port is 1080:
# ssh -R <port_on_target_machine>:<proxy_machine_address>:<correspon bindding port>
ssh -R 8123:localhost:8123 -R 1080:localhost:1080 target_machine_ip
# at target_machine:
if [[ "$1" == "off" ]]; then
unset http_proxy
unset https_proxy
unset socks_proxy
unset no_proxy
echo "proxy turned off"
else
export http_proxy=http://localhost:8123
export https_proxy=http://localhost:8123
export socks_proxy=socks://localhost:1080
export no_proxy=127.0.0.1,localhost
echo "proxy turned on"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment