Shell command return code 255

My shell command

hdmi_off: ssh [email protected] /home/pi/rpi-hdmi.sh off

Is working fine in Putty but when i call the service in HA i get following error in the log:

ERROR (MainThread) [homeassistant.components.shell_command] Error running command: ssh [email protected] /home/pi/rpi-hdmi.sh off, return code: 255
NoneType: None

What could it be?

1 Like

Hi, I’m having the same problem, could you find the solution?
Thank you

having the same issue with ssh remote command, did you find a solution for this??

1 Like

Same here. I have a simple command to sleep my iMac which runs fine from hassio shell but not from UI toggle. I think it has to do with Hass being in docker but I can’t get into the container’s shell either as the containers aren’t actually listed in Portainer.

Any tips?

create a key with ssh-keygen and then copy ssh-copy-id [email protected] to the target system using ssh-copy-id.
After that you can log in to the console without a password on the foreign system and you can do that in Home Assistant commands scripts via SSH

THIS MIGHT NOT BE BEST SECURITY PRACTICE!
But i got it working like this:
command: "/usr/bin/ssh -i /config/ssh/id_rsa -o UserKnownHostsFile=/config/ssh/known_hosts user@host 'remote_command'"
after i copied my id_rsa and known_hosts files in the locations in the config folder, so homeassistant has access to it.

Now i am not too familiar with permission stuff. So if anyone more qualified could comment further on the security implications of this, i’d appreciate it.