Skip to content

Instantly share code, notes, and snippets.

@anglinb
Created October 14, 2021 07:44
Show Gist options
  • Save anglinb/8c2b43833f3791fa69a92249d77f4cfb to your computer and use it in GitHub Desktop.
Save anglinb/8c2b43833f3791fa69a92249d77f4cfb to your computer and use it in GitHub Desktop.
Hacky VPN-like setup to quickly start a browsing session with an different IP
#!/bin/bash
cd "$(dirname "$0")/.."
set +ex
# Setup tunnel
ssh -D 9090 -N -f <user>@somehostintheus.com
# Open chrome
/Applications/Chromium.app/Contents/MacOS/Chromium --proxy-server="socks5://localhost:9090" --host-resolver-rules="MAP * ~NOTFOUND , EXCLUDE localhost"
( trap exit SIGINT ; read -r -d '' _ </dev/tty ) ## wait for Ctrl-C
# Find tunnel & quit
PID=$(lsof -i :9090 | head -n +2 | tail -n 1 | awk '{print $2}')
kill -9 $PID
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment