Sudo in Exec node

I'd like to run the following command when I press a button in the dashboard:

sudo systemctl restart socat.service

When I use the exec mode to do so, its output is this: sudo: no tty present and no askpass program specified

What's the best, most secure way of doing this? I don't want to make a security bodge....

Simple answer is you can't.. As that is an escalation of privileges it is not permitted.

The security bodge way to do it is to allow the user that you are running Node-RED with to do so by adding an explicit permission using visudo , which is standard Linux.