Created
March 25, 2022 14:28
-
-
Save imposibrus/96a42bf03c883675ea277df4688497f5 to your computer and use it in GitHub Desktop.
Simple SSH-tunnel in SystemD
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=Keeps a tunnel to 'server.com' open | |
After=network-online.target ssh.service | |
[Service] | |
# starting in user-mode: | |
User=user | |
ExecStart=/usr/bin/ssh -q -Nt -o ControlMaster=no -o ControlPath=/tmp/no -o ExitOnForwardFailure=yes -o ServerAliveInterval=15 -o ServerAliveCountMax=3 -p 22 -l user server.com -R 2224:127.0.0.1:22 -i /home/user/.ssh/id_rsa | |
# Restart every >2 seconds to avoid StartLimitInterval failure | |
RestartSec=90 | |
Restart=always | |
[Install] | |
WantedBy=multi-user.target |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment