I have a machine in a mobile carrier network with a private IP as WAN address. To be able to remotely connect to the machine I use autossh, which seems to work fine. I've created the following /usr/local/etc/rc.autossh script:
#!/bin/sh
autossh -M 19984 -N -f -o "PubkeyAuthentication=yes" -o "PasswordAuthentication=no" -i /root/.ssh/id_rsa -R 24385:localhost:22 remote-ip.somewhere.org -l remoteuser &
For starting it I did:
cat /etc/rc.conf.d/autossh
autossh_enable="YES"
When I reboot the box, this script does not seem to be up. Did I miss something or might this be because there is no default gw yet at the stage where it gets triggered?
If so, is there any way I can let the script get executed once I have a WAN IP & GW?
autossh_enable="YES" should do the trick if it's the correct rc.conf variable.
Otherwise call you script via rc.syshook "start": https://docs.opnsense.org/development/backend/autorun.html
I think there is an autossh plugin coming soon.
Cheers,
Franco
thanks, I just assumed it's the variable I would have to take, or are they "registered" somewhere? My guess was it has to be named like the rc-script I created.
"start" looks great, will check that out thanks
The "start" script works great, thanks @franco!
Yay, cool. I double-checked the FreeBSD port:
It does not ship an rc.d script so autossh_enable="YES" is never read and acted upon.
Cheers,
Franco