I’m using Tor hidden services for GUI and SSH, with a Telegram bot as fallback for when Tor occasionally decides to stop working.
I would like to be able to restart Tor via the bot, so I have added this to my configuration.yaml:
shell_command:
restart_tor: 'sudo systemctl restart tor'
When ran, I get this:
hassbian sudo[2437]: pam_unix(sudo:auth): conversation failed
hassbian sudo[2437]: pam_unix(sudo:auth): auth could not identify password for [homeassistant]
hassbian hass[2380]: 2019-01-12 23:58:15 ERROR (MainThread) [homeassistant.components.shell_command] Error running command: `systemctl restart tor`, return code: 1
hassbian hass[2380]: NoneType: None
I’m assuming user homeassistant does not have the necessary rights to do this?
Without sudo, the error is practically the same, just without the pam_unix lines.
Any ideas on how to achieve this?
EDIT:
Here’s the solution
Basically I added this line
%homeassistant ALL= NOPASSWD: /bin/systemctl restart tor
to
/etc/sudoers.d/020_homeassistant_hassbian-scripts
That file must have an empty line at the end!