the container doesn’t have the correct permissions to run commands on the host. You need to give it permission. I followed a procedure I found on here a while back but the link isn’t working right now. I’m not sure if it’s because the site is down temporarily or permanently.
Here is the link in case it starts working again:
https://hastebin.com/sojasolite.sql
I wrote down the steps from there in my procedures document and I’m pretty sure this is how I did it (substitute your details for mine):
1-Need to modify the host user privileges to skip typing your password with sudo
$ sudo visudo
add the following:
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.
Add the following to your docker command:
-v /home/hass/finity/sshkey/.ssh:/root/.ssh
3-login to container via portainer or via command line:
$ sudo docker exec -it home-assistant /bin/bash
4-generate sshkey. - ( further info - 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.