Created
October 2, 2019 09:28
-
-
Save wido/e5e9361e699c3eaaee5ae0d824882f54 to your computer and use it in GitHub Desktop.
Reverse SSH tunnel
This file contains hidden or 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 | |
## To use: `ssh -p 33333 <name>@localhost` from server | |
server="[email protected]" | |
port=$(cut -c 13-17 < /var/etc/vin) | |
localHost="localhost" | |
if [ "$server" == "[email protected]" ]; then | |
echo "Script not yet setup, quitting" | |
exit 1 | |
fi | |
while : ; do | |
RET=`ps ax | grep "$localHost:22" | grep -v "grep"` | |
if [ "$RET" = "" ];then | |
ssh -p 22 -N -T -R $port:127.0.0.1:22 -o ServerAliveInterval=3 -o StrictHostKeyChecking=no -o ExitOnForwardFailure=yes $server | |
fi | |
sleep 60 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment