I’ve been trying to figure out how to have Home Assistant suspend computers given a certain event.
My issue is not the scripting or the triggers but rather I am running the Home Assistant OS and I can’t for the life of me figure out how to create SSH keys which I can then add to the REMOTE host for passwordless ssh
I have found tons of posts about how to enable ssh TO Home Assistant OS, and several posts about sshing into a remote host from HASSIO, but those all assume the standard linux tooling.
I attempted to put a generated id_rsa/id_rsa.pub in the /mnt/boot/CONFIG directory likee you do with the authorized keys file but that didn’t work.
How do you generate SSH keys on the Home Assistant OS so that it can interact with remote machines?
Haven’t tried it myself yet, but Home Assistant OS appears to be based on Alpine Linux, and everything appears to run as root. Did you try putting the keys in /root/.ssh ? ssh-keygen exists if you use the Terminal/SSH plugin, and that will generate keys in that path by default.
Alternatively, you should be able to use the -i switch to point at the path you saved the private key to.
Looking at the docs for the Terminal/SSH addon… it says:
Regardless of how you connect (using the web terminal or using an SSH client), you end up in this add-on’s container. The Home Assistant configuration directory is located on the path /config .
following up on my own post here is what I did. After using the dropbearkey to generate the file I tried logging in with that but I was still getting a return code error of 255.
I logged into the target and confirmed that it was not receiving a connection attempt. Realizing that I ended up discovering that whatever mechanism the shell_command is using (a container?) is failing DNS resolution attempts. I switched the script to using an IP instead and I started seeing the connection attempts however I was seeing this error on the host:
After digging around some more it turns out this is because dropbearkey creates an encoded file of some sort (since Home Assistant OS does not have the file command I couldn’t tell you what type of file it outputs)
The solution to this was to run the dropbearconvert command like so
This converts the key from dropbear to openssh. After this was correct and I ensured that the script was referencing the correct keys, the shell command worked.