Created
August 20, 2017 16:32
-
-
Save bunchc/d79da2c5e4e0d4a1a98c5c725b65c182 to your computer and use it in GitHub Desktop.
Script to create reverse 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 | |
createTunnel() { | |
/usr/bin/ssh -N -R 2222:localhost:22 root@remoteaccess.isa.fuckingasshat.com | |
if [[ $? -eq 0 ]]; then | |
echo "Tunnel up!" | |
else | |
echo "No such luck, Mario. Princess is $?" | |
fi | |
} | |
ps -ef | grep "[f]uckingasshat" | |
if [[ $? -ne 0 ]]; then | |
echo "Starting tunnel" | |
createTunnel | |
else | |
echo "Tunnel already up, skipping" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment