Skip to content

Instantly share code, notes, and snippets.

@mateobur
Created May 2, 2017 18:53
Show Gist options
  • Save mateobur/748ea5f91e396cdf231fd9a8767c1f80 to your computer and use it in GitHub Desktop.
Save mateobur/748ea5f91e396cdf231fd9a8767c1f80 to your computer and use it in GitHub Desktop.
autossh ubuntu systemd
[Unit]
Description=Autossh Tunnel
Wants=network-online.target
After=network-online.target
[Service]
User=<user>
Type=simple
ExecStart=/usr/bin/autossh -M 20000 -N <host> -R 0.0.0.0:30000:localhost:22
Restart=always
RestartSec=60s
[Install]
WantedBy=multi-user.target
@mateobur
Copy link
Author

mateobur commented May 2, 2017

Autossh tunnel for ubuntu

  • First install the autossh package
  • copy the local ssh key to the remote system with ssh-copy-id
  • Replace <user> and <host>
  • Copy this script to /etc/systemd/system
  • Profit!

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