Skip to content

Instantly share code, notes, and snippets.

@ab
Created November 18, 2014 04:23
Show Gist options
  • Select an option

  • Save ab/83afb933bce967d46a80 to your computer and use it in GitHub Desktop.

Select an option

Save ab/83afb933bce967d46a80 to your computer and use it in GitHub Desktop.
Persistent SSH reverse port forward
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