gscott
Posts: 1
Joined: Sun Sep 16, 2018 2:34 pm

Getting autossh to start automatically at boot after network is up

Sun Sep 16, 2018 2:45 pm

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?

Thanks

klricks
Posts: 5769
Joined: Sat Jan 12, 2013 3:01 am
Location: Grants Pass, OR, USA
Contact: Website

Re: Getting autossh to start automatically at boot after network is up

Mon Sep 17, 2018 2:22 am

Try setting... wait for network at boot.... found in the GUI config tool or sudo raspi-config
Unless specified otherwise my response is based on the latest and fully updated Raspbian Stretch w/ Desktop OS.

tpyo kingg
Posts: 203
Joined: Mon Apr 09, 2018 5:26 pm
Location: N. Finland

Re: Getting autossh to start automatically at boot after network is up

Mon Sep 17, 2018 10:51 am

gscott wrote:
Sun Sep 16, 2018 2:45 pm
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.
What kind of unit file dependencies do you have configured there? Your task should set to wait until the networking is fully active.

Return to “Networking and servers”

Who is online

Users browsing this forum: No registered users and 10 guests