Skip to content

Instantly share code, notes, and snippets.

@aslafy-z
Forked from guettli/ssh-tunnel@.service
Last active February 16, 2024 15:03
Show Gist options
  • Save aslafy-z/24e2ddb02fa269444620eab1bcfe2932 to your computer and use it in GitHub Desktop.
Save aslafy-z/24e2ddb02fa269444620eab1bcfe2932 to your computer and use it in GitHub Desktop.
Reliable persistent SSH-Tunnel via systemd (not autossh)
# Reliable persistent SSH-Tunnel via systemd (not autossh)
# https://gist.github.com/aslafy-z/24e2ddb02fa269444620eab1bcfe2932#file-serveo-tunnel-service
#
# Usage: systemctl start serveo-tunnel@[tunnel-string] (see https://serveo.net for details)
# systemctl start serveo-tunnel@mytunnel:80:localhost:8080
# systemctl enable serveo-tunnel@mytunnel:80:localhost:8080 (to make it persist reboot)
[Unit]
Description=Serveo tunnel for %i
After=network.target
[Service]
User=root
ExecStart=/usr/bin/ssh -o "ExitOnForwardFailure yes" -o "ServerAliveInterval 60" -R %i serveo.net
Restart=always
RestartSec=5s
StartLimitInterval=0
[Install]
WantedBy=multi-user.target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment