Skip to content

Instantly share code, notes, and snippets.

@bunchc
Created August 20, 2017 16:32
Show Gist options
  • Save bunchc/d79da2c5e4e0d4a1a98c5c725b65c182 to your computer and use it in GitHub Desktop.
Save bunchc/d79da2c5e4e0d4a1a98c5c725b65c182 to your computer and use it in GitHub Desktop.
Script to create reverse SSH tunnel
#!/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