I am trying to get the following to work:
switch:
- platform: command_line
switches:
living_room_security_light:
friendly_name: Living Room Security Light
command_on: "ssh -i /config/id_rsa pi@cam '/home/pi/brightpi-control-master/white-on.sh'"
command_off: "ssh -i /config/id_rsa pi@cam '/home/pi/brightpi-control-master/all-off.sh'"
I get the following error:
...homeassistant.components.switch.command_line] Command failed: ssh -i /config/id_rsa pi@cam '/home/pi/brightpi-control-master/white-on.sh'
I tested the command by hand and it works fine. Any idea what could be wrong?
I put the private key to use inside /config. Is HA running in its Docker using the same path?
I am using hass.io with HA 0.52.1
Update: I added 2> /config/command.log
to the end of the command and can now see what is going wrong: Host key verification failed
. I now know what to do to fix this.
Update 2: Final fix. I use the following command (replace <…> with your own):
ssh -F /config/ssh_config -i /config/id_rsa <user>@<host> '<command>' 2> /config/command.log
Make sure /config/ssh_config and /config/id_rsa have 400 set as their permissions:
chmod 400 /config/ssh_config /config/id_rsa
The file /config/ssh_config
should contain:
Host *
StrictHostKeyChecking no