I’m migrating from a Ubuntu home assistant install over to Hass.io. For the most part, things are about the same to me. I learned a bit about the Docker architecture along the way which is kind of neat.
In my prior installation, I had sensors to return my various raspberry temperatures as a sensor like below:
sensor:
platform: command_line
name: Raspberry A Temp
command: “ssh [email protected] ‘cat /sys/class/thermal/thermal_zone0/temp’”
unit_of_measurement: “°F”
value_template: ‘{{ value | multiply(0.001) }}’
In order for this to work, I had to ssh-keygen in my home assistant box and add the .pub key to the authorized_hosts on my target box…
I tried doing this with the ssh addon but the .ssh directory gets wiped out every time i restart, and I’m not even sure if because of how these addons use Docker, if it’s sandboxed somewhere else and I’m not in the right environment.
Is there a way to go about ssh-keygen for Hass.io that I’ve missed?
First you need the developers SSH setup, you can find how to do it here
once you have “root@hassio:~#” prompt type “docker exec -i -t homeassistant /bin/bash”
Then follow these step But make the following change.
At step 2 save the keys to /config/ssh/id_rsa
at step 4 ssh-copy-id -i /config/ssh/id_rsa.pub hass@TARGET
To test it ssh -i /config/ssh/id_rsa hass@ TARGET
I have aan rpi2 running Hass.io with the SSH addon.
From the SSH prompt i have run ssh-keygen. This has created aan id_rsa key in the /root/.ssh folder. I copied both the private and public key to /config/ssh/
I found the issue. I was under the assumption that the ssh key could be found by the system. Instead I needed to specify the path to the key file explicitly. It is working now. For future reference, this is my working config: