Skip to content

Instantly share code, notes, and snippets.

@KalleDK
Last active October 30, 2022 19:34
Show Gist options
  • Save KalleDK/217cca2730d3597532f0e20cfccae0ae to your computer and use it in GitHub Desktop.
Save KalleDK/217cca2730d3597532f0e20cfccae0ae to your computer and use it in GitHub Desktop.
autossh
[Unit]
Description=AutoSSH
Documentation=man:autossh(1)
After=network-online.target sshd.service
[Service]
EnvironmentFile=/etc/default/autossh
EnvironmentFile=/etc/autossh/autossh.conf
ExecStart=/usr/lib/autossh/autossh -M ${MONITOR_PORT} -nNT -o ServerAliveInterval=60 -o ServerAliveCountMax=3 -o IdentitiesOnly=yes -o StrictHostKeyChecking=no -i ${TUNNEL_KEY_PATH} -R ${TUNNEL_MAPPING} ${TUNNEL_USER}@${TUNNEL_HOST}
ExecReload=kill -SIGUSR1 $MAINPID
KillMode=mixed
Restart=on-failure
RestartSec=15
Type=simple
[Install]
WantedBy=multi-user.target
Alias=autossh.service
[Unit]
Description=VerifyInternet
Documentation=man:ping(1)
After=network-online.target sshd.service
Before=autossh.service
[Service]
EnvironmentFile=/etc/default/autossh
EnvironmentFile=/etc/autossh/autossh.conf
ExecStart=/usr/bin/ping -c 1 $TUNNEL_HOST
Restart=on-failure
RestartSec=15
RemainAfterExit=yes
Type=oneshot
[Install]
WantedBy=multi-user.target
Alias=verify-internet.service
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment