Hello!
I have a problem with executeCommandLine within a Rule on my openhabian installation with Openhab 5.1.0
what have I done so far with help of the forum posts.
sudo visudo -f /etc/sudoers.d/openhab
and I have added
openhab ALL=(ALL) NOPASSWD: /sbin/shutdown, /sbin/poweroff, /sbin/systemctl, /sbin/reboot, /usr/bin/mysqldump, /usr/bin/node, /usr/bin/sshpass, /usr/bin/cat, /usr/bin/ssh
In misc/exec.whitelist of the Openhab Config I have added:
sshpass
ssh
cat
sh
sudo
/usr/bin/sshpass
I have run from putty where I was prompted to confirm the fingerprint, what I have done
sudo -u openhab ssh root@192.168.0.10
With this command from putty I can logon to the remote device
sudo -u openhab sshpass -p ‘password’ ssh root@192.168.0.10
With this command from putty I can logon to the remote device and reboot the remote device
sudo -u openhab sshpass -p ‘password’ ssh root@192.168.0.10 reboot
Now I thought I have everything to run this from a rule (fingerprint of remote device stored for user openhab, User openhab is allowed to run the commands, commands are whitellisted, confirmed that my command works from putty
So I created a rule:
rule "Test"
when Item TestDummy changed
then
val response = executeCommandLine(Duration.ofSeconds(6),"sshpass", "-p", "'password'", "ssh", "root@192.168.0.10", "reboot")
logInfo("response", "response: " + response)
end
In the logfile I can see the response
response: DD-WRT v3.0-r58976 std (c) 2025 NewMedia-NET GmbH
So I know that the login process worked, but using the rule the device does not reboot.
It looks like the reboot command which works from command line via putty, is ignored when I do it from the rule.
Your help will be much appreciated.
Regards!