Created
June 14, 2012 21:08
-
-
Save ifesdjeen/2932963 to your computer and use it in GitHub Desktop.
Persistent SSH 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
HOST = # masked | |
SOURCE_PORT = 5672 | |
DESTINATION_PORT = 5672 | |
USERNAME = ifesdjeen | |
createTunnel() { | |
/usr/bin/ssh -f -N -L$SOURCE_PORT:$HOST:$DESTINATION_PORT -L19922:HOST:22 ifesdjeen@$HOST | |
if [[ $? -eq 0 ]]; then | |
echo Tunnel to $HOST created successfully | |
else | |
echo An error occurred creating a tunnel to $HOST RC was $? | |
fi | |
} | |
/usr/bin/ssh -p 19922 $USERNAME@localhost ls | |
if [[ $? -ne 0 ]]; then | |
echo Creating new tunnel connection | |
createTunnel |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment