Skip to content

Instantly share code, notes, and snippets.

@modulsx
Forked from guettli/[email protected]
Created June 27, 2023 22:46
Show Gist options
  • Save modulsx/691c842298d3e7b7b73d46b741871a22 to your computer and use it in GitHub Desktop.
Save modulsx/691c842298d3e7b7b73d46b741871a22 to your computer and use it in GitHub Desktop.
Reliable persistent SSH-Tunnel via systemd (not autossh)
# Reliable persistent SSH-Tunnel via systemd (not autossh)
# https://gist.github.com/guettli/31242c61f00e365bbf5ed08d09cdc006#file-ssh-tunnel-service
[Unit]
Description=Tunnel for %i
After=network.target
[Service]
User=tunnel
ExecStart=/usr/bin/ssh -o "ExitOnForwardFailure yes" -o "ServerAliveInterval 60" -N tunnel@%i
Restart=always
RestartSec=5s
StartLimitInterval=0
[Install]
WantedBy=multi-user.target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment