I am trying to use a shell_command in my hass.io setup to reboot a RPi running LibreElec. I have tried the command from the command line in hass.io and it works fine, but when I create a shell_command and calls it, I get Error running command: bash reboot_kodi_kitchen.sh, return code: 255
in the logfile.
The bash file is located directly under / and I have also tried putting it in /config and calling it with
bash /config/reboot_kodi_kitchen.sh
but same thing.
The bash file I am calling issues the command ssh root@libreelec reboot. That command works from the command line too, as I have copied the ssh-key from hass.io to the RPi running LibreElec.
core-ssh:/# sudo su -s /bin/bash - homeassistant
-bash: sudo: command not found
core-ssh:/# su -s /bin/bash - homeassistant
su: unknown user homeassistant
Hmm, can you run ps aux| grep hass and post the output? I don’t have a hass environment set up (need to do that sometime) so I am guessing too. User is probably hass so you could try su ing to that user.
Ok, after a lot of googling and trial and error I solved it!
I generated a new key and put it in /config/.ssh/id_rsa
I copied the new key with ssh-copy-id to my LibreElec host
I also added a file /config/ssh_config with the following content:
Host *
StrictHostKeyChecking no
After that I was able to use the following shell_command without issues: ssh -F /config/ssh_config -i /config/.ssh/id_rsa root@ip_of_libreelec 'reboot' 2> /config/command.log
The last part is just to see the output from the host when issuing the command.