Create systemd units
- create a
<UNIT>
.service file and copy to /etc/systemd/system/<UNIT>.service
- grab template content from beneath
- run
sudo systemctl daemon-reload
to indicate that new units have been created
- check if unit is listed with
sudo systemctl list-unit-files
- start service with
sudo systemctl start <UNIT>
- check status of unit with
sudo systemctl status <UNIT>
- enable service with
sudo systemctl enable <UNIT>
to start at boot
[Unit]
Description=Service for making reverse autossh connections for OpenVPN usage
After=network-online.target
[Install]
WantedBy=multi-user.target
[Service]
Environment="AUTOSSH_GATETIME=30"
Environment="AUTOSSH_POLL=30"
Environment="AUTOSSH_FIRST_POLL=30"
Type=simple
ExecStart=/usr/bin/autossh -M 0 \
-q -gNC -f \
-o "ServerAliveInterval=60" \
-o "ServerAliveCountMax=4" \
-o "ExitOnForwardFailure=yes" \
-R 1194:192.168.1.15:2343 root@ionos.vps
ExecStop=/usr/bin/kill $MAINPID
ExecReload=/usr/bin/kill -HUP $MAINPID
Restart=always
RestartSec=60
KillMode=process