I have a Victron Cerbo GX with Venus OS and a node-red v3.1.10 instance is running there. Node-red itself works fine, but I have a problem that I lost remote access to the device via ssh. Access is only from the local network, but now I'm far away and unfortunately I don't have the ability to log in from the local network. Node-red is started by the nodered user and I need root access. I know the root password, I have access to the device console etc.
I could modify rc.local to start VPN and restore access. I'm trying to run various commands in the exec node, but everything works for the nodered user, using sudo requires entering the password from the terminal and this can't be done in the node, and ASK_SUDO and then sudo -A doesn't work in the exec node although I know it works on Venus OS itself (I checked on another device with the same configuration).
Does anyone have an idea how to run commands in the exec node as root?
A better idea, avoiding using your password in plain text in the flows file, is to use sudo your_command in the exec node, and, in a command window, run sudo visudo to allow the node red user to run that command with sudo without having to enter a password.
So, for example, to allow the use of sudo shutdown in an exec node, for the user nodered, use sudo visudo and add
@dynamicdave and @jbudd
Passing the password this way does not work on my Node-red instance. I tried a few other methods and they don't work in Node-red either.
@Colin
Modifying sudoers is possible for root via ssh, but I don't have that access and I want to get it. I'll do it when I get access
I spent quite a bit of time trying different ways to get around the limitations of VenusOS on a Cerbo GX using Node-red - mostly to try and regain access or run privileged commands directly from a flow. And turns out not much luck
Even though echo 'password' | sudo -S ... works fine in a terminal, it doesn’t behave the same in a node-red exec node. Looks like stdin doesn’t get passed to sudo properly in that context.
VenusOS comes with a super minimal version of sudo, no support for sudo_askpass (checked with sudo -V, nothing mentioned) and requires tty for password input, which node-red obviously doesn’t have.
I tried all the usual tricks (echo + sudo, askpass, custom scripts) but it always ends up failing or just silently doing nothing. So yeah, its not really possible to elevate privileges through ode-red alone on this system.
Guess I’ll need to find someone local to connetc into the Cerbo and fix things manually.