Skip to content

Instantly share code, notes, and snippets.

@designermonkey
Forked from thomasfr/autossh.service
Created December 6, 2015 12:28
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save designermonkey/bf0a02617ced4e5a9dc0 to your computer and use it in GitHub Desktop.
Save designermonkey/bf0a02617ced4e5a9dc0 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 60" -o "ServerAliveCountMax 3" -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
@fedecupe
Copy link

fedecupe commented May 27, 2017

maybe change to After=network-online.target

@lifeboy
Copy link

lifeboy commented Jul 19, 2017

This sounds simple enough, but I couldn't get this to work. This thing starts and then ssh exists on signal 15 for no reason.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment