Skip to content

Instantly share code, notes, and snippets.

@valerio-bozzolan
Forked from thomasfr/autossh.service
Last active May 12, 2020 13:06
Show Gist options
  • Save valerio-bozzolan/c6a4cc9f827f9cd9332e16d44229a17f to your computer and use it in GitHub Desktop.
Save valerio-bozzolan/c6a4cc9f827f9cd9332e16d44229a17f to your computer and use it in GitHub Desktop.
Systemd service for autossh
[Unit]
Description=Keeps a tunnel to 'remote.example.com' open
After=network.target
[Service]
User=autossh
# -p [PORT]
# -l [user]
# -M 0 --> no monitoring
# -N Just open the connection and do nothing (not interactive)
# LOCALPORT:IP_ON_EXAMPLE_COM:PORT_ON_EXAMPLE_COM
ExecStart=/usr/bin/autossh -M 0 -N -q -o "ServerAliveInterval 40" -o "ServerAliveCountMax 1" -o ExitOnForwardFailure=yes -p 22 -l autossh remote.example.com -L 7474:127.0.0.1:7474 -i /home/autossh/.ssh/id_rsa
[Install]
WantedBy=multi-user.target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment