Skip to content

Instantly share code, notes, and snippets.

@magcks
Created November 27, 2013 17:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save magcks/7679303 to your computer and use it in GitHub Desktop.
Save magcks/7679303 to your computer and use it in GitHub Desktop.
#!/bin/sh
URL="$1"
LOCAL_PORT=1337
TU_ID=topsecret
RBG_CLIENT=1
PROT=$(cut -d: -f1 <<< $URL)
DOM=$(cut -d/ -f3 <<< $URL)
URLPATH=$(cut -d/ -f4- <<< $URL)
if [ "$PROT" == "http" ]; then
PORT=80
else
PORT=443
fi
# establish ssh connection
ssh -N -f -L${LOCAL_PORT}:${DOM}:${PORT} ${TU_ID}@clientssh${RBG_CLIENT}.rbg.informatik.tu-darmstadt.de
PID=$(netstat -tpln 2> /dev/null | grep 127\.0\.0\.1:${LOCAL_PORT} | awk '{print $7}' | sed 's#/.*##')
echo "#### PID is $PID ####"
# download
wget "${PROT}://localhost:${LOCAL_PORT}/${URLPATH}"
# kill ssh tunnel
kill $PID
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment