Created
August 24, 2017 12:53
-
-
Save TotalLag/b4dae4e2bfc0b44a87d0123e973ddf01 to your computer and use it in GitHub Desktop.
persistent tunnel
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 | |
createTunnel() { | |
/usr/bin/ssh -N -R 2222:localhost:22 serverUser@25.25.25.25 | |
if [[ $? -eq 0 ]]; then | |
echo Tunnel to jumpbox created successfully | |
else | |
echo An error occurred creating a tunnel to jumpbox. RC was $? | |
fi | |
} | |
/bin/pidof ssh | |
if [[ $? -ne 0 ]]; then | |
echo Creating new tunnel connection | |
createTunnel | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment