Ssh remote into another pi help

Hi guys,
I’m trying to set up a command that will allow me to trigger a reboot on another PI from home assistant. I’ve created the required keys and I’m able within the ssh terminal add on to ssh via

ssh [email protected]

yet when I add the following shell command it doesn’t work

  trigger_reboot: 'ssh [email protected] sudo shutdown -Ph now'

could someone please help

If you’re running Home Assistant OS, Supervised, or Container, then the problem is that it can’t find the keys, and doesn’t know to accept the server key.

See this article, but in summary you need to put the keys under /config/ and do:

ssh -i /config/ssh/id_ed25519 -o StrictHostKeyChecking=accept-new [email protected] sudo shutdown -Ph now

Obviously the pi account needs to be able to run that sudo command without being prompted for a password.

thank you
I created the keys and moved them to a folder in the config