Last active
January 29, 2022 10:44
-
-
Save bonnee/f78f25fc44413fbadbe26a3dd12a2149 to your computer and use it in GitHub Desktop.
Systemd service file to keep an ssh reverse tunnel open
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 home open | |
After=network.target | |
[Service] | |
User=<username> | |
# -p [PORT] | |
# -l [user] | |
# -M 0 --> no monitoring | |
# -N Just open the connection and do nothing (not interactive) | |
# LOCALPORT:IP_ON_EXAMPLE_COM:PORT_ON_EXAMPLE_COM | |
ExecStart=/usr/bin/ssh -g -NC -tt -o "ServerAliveInterval=10" -o "ExitOnForwardFailure=yes" -o "StrictHostKeyChecking=no" -R <local_port>:127.0.0.1:22 <local_user>@<public_ip> -p 8481 | |
Restart=always | |
RestartSec=30 | |
[Install] | |
WantedBy=multi-user.target |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment