Skip to content

Instantly share code, notes, and snippets.

@plieningerweb
Created November 29, 2016 15:50
Show Gist options
  • Save plieningerweb/1df8af65d9bd40488b8ea26befdbe977 to your computer and use it in GitHub Desktop.
Save plieningerweb/1df8af65d9bd40488b8ea26befdbe977 to your computer and use it in GitHub Desktop.
Autossh Systemd

copy into /etc/systemd/system/autossh-ssh.service

[Unit]
Description=Reverse tunnel for ssh
After=network.target

[Service]
User=pi
Environment="AUTOSSH_GATETIME=0"
ExecStart=/usr/bin/autossh -M 0 -oExitOnForwardFailure=yes -oStrictHostKeyChecking=no -oServerAliveInterval=30 -oServerAliveCountMax=2 -R {{autossh_reverse_remote_port}}:localhost:22 -N {{autossh_remote_host}}
Restart=always
RestartSec=60

[Install]
WantedBy=multi-user.target

run

systemctl daemon-reload
systemctl enable autossh-ssh
systemctl start autossh-ssh
systemctl status autossh-ssh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment