RemoteManager - Managed SSH Port forwarding
The tunnel can only be enabled if the remote server is onboarding the devices public key. This will only be made if the Backend knows that a tunnel should be established.
Configuration
/config/os/esec/RemoteManager.conf
/config/os/esec/RemoteManager.conf.sig
DeviceName=BHT-0002-02-0000030ServerURL=my.server.urlPrivateKey=/config/os/root/.ssh/id_ecdsaServerReversePort=10203ConnectionSleepTimeSec=300IdleSleepTimeSec=60ReverseConnectionActive=trueServerSshPort=22HostPort=22Scheduling
systemd Example
/etc/systemd/system/remotemanager.service
[Unit]Description=Remote SSH ManagerAfter=network.targetStartLimitIntervalSec=0[Service]Type=simpleRestart=alwaysRestartSec=5User=rootExecStart=/usr/local/bin/RemoteManagerWorkingDirectory=/config/os/esec/[Install]WantedBy=multi-user.targetExample Tunnel Script
#!/bin/shConfigFile="./RemoteManager.conf"while truedo if . $ConfigFile then if [ -z $ServerSshPort ] then ServerSshPort=22 fi if [ -z $HostPort ] then HostPort=22 fi if $ReverseConnectionActive then echo "connecting to $ServerURL as $DeviceName via SSH" echo "closing connection in $ConnectionSleepTimeSec seconds" if ssh -i "$PrivateKey" -o "ConnectTimeout=5" -o "ServerAliveInterval=5" -o "StrictHostKeyChecking=no" -p $ServerSshPort -R $ServerReversePort:localhost:$HostPort $DeviceName@$ServerURL sleep $ConnectionSleepTimeSec then echo "ssh connection closed successfully" else echo "ssh connection failed, sleeping $IdleSleepTimeSec seconds" >&2 sleep $IdleSleepTimeSec fi else echo "Reverse Connection inactive" echo "sleeping for $IdleSleepTimeSec seconds" sleep $IdleSleepTimeSec fi else exit 1 fidone