Created
August 16, 2015 15:20
-
-
Save urish/223a193c550ef55d7101 to your computer and use it in GitHub Desktop.
Raspberry Pi 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
#!/bin/bash | |
# Based on: http://www.tunnelsup.com/raspberry-pi-phoning-home-using-a-reverse-remote-ssh-tunnel | |
createTunnel() { | |
/usr/bin/ssh -o ServerAliveInterval=5 -o ServerAliveCountMax=1 -N -R 0.0.0.0:2222:localhost:22 fwd1@RemoteHost | |
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