Last active
October 7, 2020 01:45
-
-
Save ntrepid8/0af12c012dd2567c800799d86eb44f90 to your computer and use it in GitHub Desktop.
AutoSSH reverse tunnel service config for 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=AutoSSH reverse tunnel service for jump.you.io 100022 -> 22 | |
After=network.target | |
[Service] | |
Environment="AUTOSSH_GATETIME=0" | |
ExecStart=/usr/bin/autossh -M 0 -o "ExitOnForwardFailure=yes" -o "ServerAliveInterval 30" -o "ServerAliveCountMax 3" -NR 10022:127.0.0.1:22 [email protected] -i /home/root/.ssh/id_rsa | |
[Install] | |
WantedBy=multi-user.target |
I've munged something based on this, though I'm using /root/.ssh/config
to manage most of the connection options. I ran into some trouble because I had left the -f
option on the autossh
command I'd been running manually before. Removing that fixed it. My line is ExecStart=/usr/bin/autossh -M 0 -NT tunnel
. I have this all set up because I am tunneling through a bastion host to get to the actual machine I want to port forward from.
As https://unix.stackexchange.com/a/379991/47775 mentioned you could change the After target with network-online.target
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To enable to service unit in systemd do the following: