Linux Docker Home Assistant User

I have set up Home Assistant in Docker on Ubuntu Linux and everything is working well. I have added a command line switch.

switch:
platform: command_line
switches:
  wifi:
    command_on: ssh [email protected] '(echo "enable" ; echo "configure" ; echo "interface '0/7'" ; echo "poe opmode auto" ; echo "exit" ; echo "exit" ; echo "exit") | telnet localhost 23 ; exit;'
    command_off: ssh [email protected] '(echo "enable" ; echo "configure" ; echo "interface '0/7'" ; echo "poe opmode shutdown" ; echo "exit" ; echo "exit" ; echo "exit") | telnet localhost 23 ; exit;'
    friendly_name: Wifi PoE Switch

The ssh commands work perfectly when excited from the Ubuntu user account since I have set up authorization keys. But when I trigger from HA they fail which I suspect is because the ssh authorization key is tied to the Ubunutu user not the HA docker container user. I assume I need to get a public key for the HA container so it can ssh into my server but I am not sure how to do that. I am new to docker and HA so any help would be appreciated.

Well I have solved this by switching to a direct install in Ubuntu that does not have this issue.

You could have mounted your ~/.ssh as a volume bind to the root user in the container and passed the keys through.

You gave up way too easily. :wink:

Well you are probably right but since I am running on a Proxmox host a LXC container with ubuntu/ha is actually lighter than a virtual machine with ubuntu/docker/ha. If I ever start using more docker images maybe it will be worth sorting out.

Thanks for the suggestion.