Command line switch - sending failed with passphrased ssh key

I made a manual installation of HA on RPi and run HA as homeassistant user. I created new ssh key for homeassistant put public key on my other RPI (running Rasplex). I can connect and send the desired command via terminal, but not as command line switch.

 -  platform: command_line
switches:
  plex:
    command_on: ssh root@[IP] "echo 'on 0' | cec-client -s"
    command_off: ssh root@[IP] "echo 'standby 0' | cec-client -s"
    friendly_name: TV

The error I am getting is:

ERROR (Thread-11) [homeassistant.components.switch.command_line] Command failed: ssh root@[IP]"echo 'on 0' | cec-client -s"

I found a workaround… when I don’t have passphrase on my ssh key the command go through, but I would rather have the passphrase on my ssh key. Thanks for help.

Are you saying when the pub/private key has the extra passphrase the command won’t work?

Do you need the passphrase when you’re just ssh’ing over LAN? I mean why not make a 4096 bit keypair?

Well, I have a 4096 key :slight_smile: but it’s bugging me that I can’t find a solution with passphrase.

I don’t know if it is possible to use a passphrased ssh key, but I would suggest to not use the root user to connect to the other pi.

Thanks for reply. Yes, that’s a good advice, I am using ssh key made just for HA.

Not sure if this helps but it might give you a hint where to go. http://stackoverflow.com/questions/4780893/use-expect-in-bash-script-to-provide-password-to-ssh-command

~Cheers