Created
September 19, 2022 22:28
-
-
Save devenes/663132ea45ccae1073bfc1905024e574 to your computer and use it in GitHub Desktop.
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
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