Can anyone point me in the direction of a good (step by step) resource for setting up a reverse ssh tunnel with autossh using systemd at boot?
I've tried my best to do this using resources I've found online and have succeeded in manually creating the reverse ssh session, however haven't managed to automate it with systemd such that my "remote" system can reboot without causing issues.
I'm trying to establish a persistent autossh session using this tutorial, however when I run sudo systemctl enable autossh.service
I keep running into this error: update-rc.d: error: cannot find a LSB script for autossh
.
Any help deciphering this error or creating a persistent autossh session on Ubuntu 20.04 would be greatly appreciated.
autossh.service
file:
[Unit]
Description=Establish persistent SSH tunnel
Requires=ssh.service
Wants=network-online.target
After=network-online.target
[Service]
User=user
Group=usergroup
Environment=AUTOSSH_POLL=60 AUTOSSH_FIRST_POLL=30 AUTOSSH_LOGFILE=/var/log/autossh.log AUTOSSH_LOGLEVEL=7 AUTOSSH_GATETIME=0
ExecStart=/usr/bin/autossh -i /root/.ssh/id_rsa -R 3010:localhost:22 -o 'StrictHostKeyChecking=no' -o 'UserKnownHostsFile=/dev/null' -o 'PasswordAuthentication=no' -o 'PubkeyAuthentication=yes' -o 'ServerAliveInterval 60' -o 'ServerAliveCountMax 3' -o 'BatchMode=yes' user@myddnsservice -p2016
RestartSec=6
Restart=always
[Install]
WantedBy=multi-user.target