Skip to content

Instantly share code, notes, and snippets.

@zmpeg
Last active August 12, 2019 20:15
Show Gist options
  • Save zmpeg/8911e3b78a8873612e17 to your computer and use it in GitHub Desktop.
Save zmpeg/8911e3b78a8873612e17 to your computer and use it in GitHub Desktop.
go.sh

go.sh

A simple script to open a dynamic ssh tunnel to your server and connect a fresh chrome browser to it via the socks5 proxy.

Installation

Clone the repo and maybe symlink/shortcut the version you need to somewhere convenient.

git clone https://gist.github.com/8911e3b78a8873612e17.git $HOME/opt/go.sh
ln -s $HOME/opt/go.sh/go-mac.sh $HOME/bin/go.sh

Configuration

For now just edit the script itself and set your ssh server. I recommend using key-based authentication, to skip the password prompt each time.

Usage

Now you can get a fresh browser connected to your ssh server at the drop of a command

# go

Todo

  1. Add an env file to load the correct hostname
#!/bin/sh
#
# USAGE: ./go.sh [server]
# Will connect to either the default server below, or the specified one.
# Relies on SSH keys to make the connection without entering a password.
#
CHROME=`which chromium-browser`
PROXY=mjz.me
TIMESTAMP=`date +%Y%m%d%H%M%S`
SESSIONDIR=/tmp/google-chrome-$TIMESTAMP-$RANDOM
URLS="jsonip.com"
ssh -ND 58008 $PROXY > /dev/null 2> /dev/null &
TERM_PID=$!
$CHROME --user-data-dir=$SESSIONDIR --incognito --proxy-server=socks://localhost:58008 $URLS > /dev/null 2> /dev/null
kill -9 "${TERM_PID}"
rm -rf $SESSIONDIR
#!/bin/sh
#
#
PROXY=mjz.me
TIMESTAMP=`date +%Y%m%d%H%M%S`
SESSIONDIR=/tmp/google-chrome-$TIMESTAMP-$RANDOM
mkdir -p $SESSIONDIR
ssh -ND 58008 $PROXY > /dev/null 2> /dev/null &
TERM_PID=$!
open -W -na "Google Chrome" --args --no-first-run --user-data-dir=$SESSIONDIR --incognito --proxy-server=socks5://localhost:58008 "http://jsonip.com"
kill "${TERM_PID}"
rm -rf $SESSIONDIR
start chrome --user-data-dir="%temp%/chrome-go-sh" --proxy-server="socks5://localhost:8222"
"C:\Program Files (x86)\PuTTY\plink.exe" -ssh "mjz.me" -D "127.0.0.1:8222" -noagent -i "C:%homepath%\.ssh\id_rsa.ppk" -N
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment