I’ve been trying all day to get this to work with no luck.
I’m trying to send a command to my PC to sleep over SSH from my Home Assistant (installed Home Assistant OS on Raspberry Pi 4). I’m trying to figure out the SSH keys so I can have the SSH command trigger without needing my Windows Machine’s password. I generated a key using “ssh-keygen” on windows and copied the contents of the id_rsa to a file in my config “/config/ssh_keys/id_rsa” as outlined in this post (Power on / off NAS by using WOL and SSHPASS - #2 by Lucan).
So my shell command is:
ssh -i /config/ssh_keys/id_rsa -o StrictHostKeyChecking=no [email protected]_of_windows "powercfg -h off & rundll32.exe powrprof.dll,SetSuspendState 0,1,0"
However it still asks for the password when I test it in the SSH terminal on the Home Assistant.
I was eventually able to get it working through the terminal in Home Assistant by adding the HA’s public key to my Windows Machine’s authorized keys in “C:\Users\username.ssh\authorized_keys” as outlined in this video (Windows 10 SSH with Public Key Authentication - YouTube)
I’m able to connect without a password just fine with just a standard ssh command! HOWEVER, it doesn’t work when it runs through the shell_command script, it just errors saying: “Permission Denied (publickey, keyboard-interactive)”
So close yet so far. Any help would be greatly appriciated!