Skip to content

Instantly share code, notes, and snippets.

@TotalLag
Created August 24, 2017 12:53
Show Gist options
  • Save TotalLag/b4dae4e2bfc0b44a87d0123e973ddf01 to your computer and use it in GitHub Desktop.
Save TotalLag/b4dae4e2bfc0b44a87d0123e973ddf01 to your computer and use it in GitHub Desktop.
persistent tunnel
#!/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