Last active
May 5, 2021 06:44
-
-
Save brettbeeson/43f50e164f30e83b367c90a1942b1e6a to your computer and use it in GitHub Desktop.
autossh systemd service
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Unit] | |
Description=Auto Reverse SSH | |
# No - can fail on dependancy. No sure best way to do this. | |
# Requires=systemd-networkd-wait-online.service | |
After=systemd-networkd-wait-online.service | |
# Try to restart forever! | |
StartLimitIntervalSec=0 | |
StartLimitInterval=0 | |
[Service] | |
# run as a user who has .ssh/id_rsa private key available (usually not root) | |
User=pi | |
Type=simple | |
Restart=always | |
RestartSec=60 | |
[Service] | |
ExecStart=/usr/bin/autossh -M 0 -N -R 0:localhost:22 ***user@public.com*** -o ForwardX11=no -o ExitOnForwardFailure=yes -o StrictHostKeyChecking=no -o ServerAliveInterval=20 | |
[Install] | |
WantedBy=multi-user.target |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment