Created
November 18, 2014 04:23
-
-
Save ab/83afb933bce967d46a80 to your computer and use it in GitHub Desktop.
Persistent SSH reverse port forward
This file contains hidden or 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
| description "autossh tunnel to HOST" | |
| author "Andy Brody" | |
| start on (local-filesystems and net-device-up IFACE=eth0) | |
| stop on runlevel [016] | |
| respawn | |
| respawn limit unlimited | |
| setuid tunnel | |
| setgid nogroup | |
| console output | |
| exec autossh -M 0 -v -N -R 1234:localhost:22 -o 'ServerAliveInterval 60' -o 'ServerAliveCountMax 2' -o 'BatchMode=yes' -o 'ExitOnForwardFailure yes' -i /etc/ssh/tunnel/id_rsa tunnel@HOST 2>&1 | logger -t autossh-ssh | |
| # post-stop exec sleep 20 | |
| post-stop script | |
| echo 'exited; sleeping 20' | logger -t autossh-init | |
| sleep 20 | |
| end script |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment