Skip to content

Instantly share code, notes, and snippets.

@alejor
Created November 3, 2017 22:19
Show Gist options
  • Save alejor/e0d2eec712a31e3fe2323484ebc33312 to your computer and use it in GitHub Desktop.
Save alejor/e0d2eec712a31e3fe2323484ebc33312 to your computer and use it in GitHub Desktop.
Remote Tunnel Systemd Unit
[Unit]
Description=Setup a secure tunnel to %I
After=network.target
[Service]
User=root
EnvironmentFile=/etc/default/secure-tunnel@%i
ExecStart=/usr/bin/ssh -NT -o ServerAliveInterval=60 -o ExitOnForwardFailure=yes -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -p ${SSH_PORT} -R ${REMOTE_PORT}:localhost:${LOCAL_PORT} ${TARGET}
# Restart every >2 seconds to avoid StartLimitInterval failure
RestartSec=90
Restart=always
[Install]
WantedBy=multi-user.target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment