Skip to content

Instantly share code, notes, and snippets.

@spvkgn
Last active July 3, 2017 05:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save spvkgn/de9895ca0cc8ab49157c704d8d1631e8 to your computer and use it in GitHub Desktop.
Save spvkgn/de9895ca0cc8ab49157c704d8d1631e8 to your computer and use it in GitHub Desktop.
AutoSSH tunnel systemd unit
[Unit]
Description=AutoSSH service for a reverse tunnel from some.example.com to localhost
After=network.target
After=networking.service
[Service]
Environment=AUTOSSH_FIRST_POLL=30
Environment=AUTOSSH_GATETIME=0
Environment=AUTOSSH_POLL=60
Environment=USERNAME=user
Environment=HOSTNAME=host
User=user
Group=user
ExecStart=/usr/bin/autossh -M 0 -ND 1080 -o "ServerAliveInterval 60" -o "ServerAliveCountMax 3" -i /home/user/.ssh/id_rsa ${USERNAME}@${HOSTNAME}
[Install]
WantedBy=multi-user.target
@spvkgn
Copy link
Author

spvkgn commented Jun 9, 2017

put here /etc/systemd/system/autossh.service
systemctl enable autossh.service
systemctl start autossh.service

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