Last active
March 5, 2023 20:08
-
-
Save luisehk/a2f1349a001b2cbc919e9b3b059c6917 to your computer and use it in GitHub Desktop.
Reverse SSH tunnel as a 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
#!/bin/bash | |
echo 'Starting reverse SSH tunnel' | |
/usr/bin/autossh -M 0 -o "ServerAliveInterval 30" -o "ServerAliveCountMax 3" -o "ExitOnForwardFailure=yes" -tt -R \*:2222:localhost:22 user@your.server |
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=Phone home using SSH | |
ConditionPathExists=|/usr/bin | |
After=network.target | |
[Service] | |
User=user | |
ExecStart=/home/user/bin/autossh.sh | |
RestartSec=3 | |
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
Also requires you to: