Skip to content

Instantly share code, notes, and snippets.

@devenes
Created September 19, 2022 22:28
Show Gist options
  • Save devenes/663132ea45ccae1073bfc1905024e574 to your computer and use it in GitHub Desktop.
Save devenes/663132ea45ccae1073bfc1905024e574 to your computer and use it in GitHub Desktop.
i=0
while test 1==1
do
remote_ip=10.25.10.10
remote_user=enes
local_port=22
exist=`ps aux | grep $remote_user@$remote_ip | grep $local_port`
if test -n "$exist"
then
if test $i -eq 0
then
echo "I'm alive since $(date)"
fi
i=1
else
i=0
echo "I died... God is bringing me back..."
ssh $remote_user@$remote_ip -f -N -D 0.0.0.0:$local_port
fi
sleep 1
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment