I have what I thought was going to be a simple task but I have had a heck of a time finding a reliable solution.
Project: Run the PI offsite with syncthing as an offsite storage. To do this I want to run autossh with a reverse ssh tunnel so I can remote into the device for maintenance.
Problem: Getting autossh to reliably start and run automatically after bootup. I have the reverse ssh tunnel working properly with autossh when started manually.
I've tried a number of things so far to automate this
1. cron job - ssh does not have access to full env when started from cron, so it fails to start
2. update-rc.d - was able to get autossh to start automatically at bootup, however it network is not available at the time autossh starts, so it exits and doesn't recover.
3. systemd - tried setting up a service for this, and can confirm that manually starting and stopping the service brings up autossh, however it doesn't seem to start automatically at boot.
Is there a preferred/suggested way to do this on raspbian?