Created
January 1, 2023 23:57
-
-
Save airone01/eb1f669579f309be48a530e61f8c3290 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 service | |
After=network.target | |
[Service] | |
Type=simple | |
User=user | |
Group=group | |
Environment="AUTOSSH_GATETIME=0" | |
ExecStart=/usr/bin/autossh -N -M 0 -o "ServerAliveInterval 30" -o "ServerAliveCountMax 3" -L %i:localhost:%i user@remote | |
[Install] | |
WantedBy=multi-user.target |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
A systemd service script for autossh port tunelling.
Run with
systemctl start autossh@yourport
Don't forget to edit the file (user, group, remote host and remote user). This script assumes that you use public/private ssh key pairs, so that you don't have to handle passwords and this can be used automatically. Read about ssh key pairs here
Field-tested by me, but don't take my word for it and double-check the script and your configuration.
More info
Notes
-- -4
at the end of theExecStart
command