OpenHAB sudo [Exec Binding]

Can someone tell me, how i can give sudoers-rights to user openhab only for the command “systemctl” ?

I want to start / stop / restart openhab service with a script from inside openhab.

This is my sudoers-file and it seems to work only partially:

Cmnd_Alias SHUTDOWN_CMDS = /sbin/poweroff, /sbin/halt, /sbin/reboot, /bin/systemctl
Cmnd_Alias UPDATE_COMMANDS = /usr/bin/apt-get

openhab ALL=(ALL) NOPASSWD: SHUTDOWN_CMDS, UPDATE_COMMANDS

I think reboot works, but systemctl-commands don´t work. There i get still a passwort-promt.

My openhab-server runs on latest debian-version.

1 Like