Sudo commands via ssh from HA

I am trying to send some sudo commands via ssh using the homeassistant user, but it requires a password when I do this from the terminal, even though I copied my public keys to the remote machine.
What am I missing? Can the user homeassistant send sudo commands without requiring password? or home assistant?

Oh, yea… Sorry for not mentioning… Home assistant in a venv. I am trying to ssh to another raspberry.
I did so much googling that I was in the rush of asking here. I am trying to figure this out for a long time.

Ok… so you’ll need to reference a file (on the pi you are ssh’ing from) that contains the key when you ssh into the other pi… that should work fine.

Something like:

ssh -i key.txt [email protected]

I don’t know if you need to use sudo before ssh…

Ah, thank you very much. That worked!

restartcopicat: 'ssh -i /home/homeassistant/.ssh/id_rsa [email protected] sudo reboot'
1 Like