Ssh command in command line switch failed

Hi!

I’m having trouble with a command line switch with an ssh command

this is my configuration.yaml snippet:

switch:
  - platform: command_line
    switches:
      win10:
        command_on: "ssh -i /config/.ssh/id_ed25519 [email protected] sudo virsh start win10"
        command_off: "ssh -i /config/.ssh/id_ed25519 [email protected] sudo virsh destroy win10"
        command_state: "ssh -i /config/.ssh/id_ed25519 [email protected] sudo virsh dominfo win10 | grep running"
        friendly_name: "Windows VM"

error message:

Command failed: ssh -i /config/.ssh/id_ed25519 [email protected] sudo virsh start win10

I put the ssh keys in the config directory because of this answer.
If I run the commands from the ssh terminal plugin it works just fine…

Additional Information:
Hassio 0.107.7 on RPi4

Thank you for your help!

For anyone having the same issue,
I looked around a bit and found this solution:

switch:
  - platform: command_line
    switches:
      win10:
        command_on: "ssh -i /config/.ssh/id_ed25519 -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no [email protected] sudo virsh start win10"
        command_off: "ssh -i /config/.ssh/id_ed25519 -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no [email protected] sudo virsh destroy win10"
        command_state: "ssh -i /config/.ssh/id_ed25519 -o UserknownHostsFile=/dev/null -o StrictHostKeyCHecking=no [email protected] sudo virsh dominfo win10 | grep laufend"
        friendly_name: "Windows VM"