Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save austindoeswork/6ee7b43868d189edc84809a1ddf1f7bd to your computer and use it in GitHub Desktop.
Save austindoeswork/6ee7b43868d189edc84809a1ddf1f7bd to your computer and use it in GitHub Desktop.
auto restarting socks5 ssh proxy
#!/bin/bash
while [ true ]
do
echo "starting socks5 proxy at localhost:22222"
ssh -A -ND localhost:22222 metrics@bastion.prodnext.ottoq.com -v &
LASTPID=$!
ALIVE=true
while [ $ALIVE = true ]
do
sleep 1m
curl -s --socks5 localhost:22222 binfalse.de > /dev/null
if [[ $? -eq 0 ]]; then
echo "sock check success"
else
echo "sock check failure, restarting"
ALIVE=false
fi
done
kill -9 $LASTPID
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment