Created
August 9, 2016 21:32
-
-
Save austindoeswork/6ee7b43868d189edc84809a1ddf1f7bd to your computer and use it in GitHub Desktop.
auto restarting socks5 ssh proxy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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