but be aware that when you get to step 5 it won’t work if you have an existing authorized_keys file. You have to copy the key manually into the file. Put one key per line with no lines between them.
Well, isn’t that weird. I went to the site to verify that it was still a good link right before I posted it and everything was there. Now it’s blank…
Anyway here is the procedure as I have it in my notes:
1-Need to modify the host user privileges to skip typing your password with sudo
sudo visudo
hostuser ALL=(ALL) NOPASSWD:ALL
2-create the following directory:
$ mkdir /home/finity/docker/sshkey/.ssh
Then mount this volume in HA container to preserve the sshkey generated from the HA container and used to execute shell commands. Key will then persist through reboot or upgrades.
-v /home/hass/finity/sshkey/.ssh:/root/.ssh
3-login to container via portainer or
$ sudo docker exec -it home-assistant /bin/bash
4-generate sshkey. - https://www.digitalocean.com/community/tutorials/how-to-set-up-ssh-keys--2
$ ssh-keygen -t rsa (press enter, enter, enter)
5-copy the sshkey to your host ***
$ ssh-copy-id [email protected] (type password when prompted)
*** this won’t work if you have an existing authorized_keys file. You have to copy the key manually into the file. Put one key per line with no lines between them.
If I remember correctly, I think that’s all I had to do.
Hi, I was looking for something similar and this was the first google result. Yet, please note a nice alternative with pipes is possible and well explained here. This approach doesn’t required SSH from container to host, which is not ideal on security level.