Hello everyone, I wanted to know if it is possible to run a command or script on the local machine outside of the home assistant container. Because it is the only way I have to control the ip camera with PTZ commands using onvif-ptz. Which was installed with the local user on my computer.
I am trying to do this, testing it on home assistant terminal, i can connect via ssh using passfrase
This is the same behavior exhibited when I ran shell commands from HA to another pi, so I’m guessing the fix is the same. I needed to exchange keys and store them in a specific directory to get them to persist. Here is the guide I followed.
The credentials for ssh are created and I can enter from home assistant to the same ip where it runs without problems. Only when executing command I have that error
Right exactly what happened to me I could ssh in and run the command but couldn’t send the ssh command. On first login keys are exchanged and saved to root, that won’t work.
However there is one key exception, do not store your key file in the default location. The default location for ssh-keygen is ~/.ssh which translates to /root/.ssh. You should not store anything in /root for a few reasons:
It is not a shared folder between the docker containers. The SSH & Terminal add-on is actually a different docker container then the HA application which means they do not share a filesystem, they only share specific folders such as /config and /share. /root is not shared so anything you put in that folder while ssh’ed in like this is not visible to HA.
Even if you do get to /root of the actual HA container, don’t use it. Only specific folders such as /config and /share are preserved across updates, everything else is wiped clean. So anything you do have stored in /root in the HA container will be lost next update.
Instead I’d recommend telling ssh-keygen to store its generated ID file in /config/.ssh. You don’t have to put it in a folder called .ssh if you don’t want to, I just like the consistency. But you should put it in /config so it is preserved over updates.
Also
The SSH & Web Terminal from the list of community add-ons set up and with protection mode disabled (this is necessary to be able to execute commands on specific containers, more on this below)
Finally your command will need to specify the key location.
I was finally able to do it, now I can create a button or switch that calls the shell command and it connects by ssh to the remote computer and executes the command without problems. I
copy the keys to a directory accessible by HA ( config/.ssh )and also known_hosts and now it works!
Thanks MikeFila to point me in the correct direction!!