I’m trying to make a shell_command that will use ssh to run a command against a remote server.
I’ve setup ssh keys and if I use the terminal, I can run the script with no problems, but when I run the shell_command via an automation it’s not authenticated.
I am far, far from expert, but my understanding is that when you log in using SSH, you are root.
When you use the shell_command, the user/owner is HomeAssistant.
I’d imagine the shell_command runs as whatever user started homeassistant, which in almost all cases will be the homeassistant user. However, once you’ve SSHed to the remote server, it’s whoever you specified the user as, in your case aaron.
As has been eluded to, SSH key permissions can be a real pain. They need to be readable by the user accessing them AND NOBDOY ELSE!!! That chmod command should do it, just make sure that homeassistant is also the owner of the file.
One more thing, I guess you don’t want to be left with some interactive SSH terminal, since all this is running in a script. You should specify the command(s) you want to run on the remote on that SSH line. The SSH line should look something like:
Closing this out, the above guides work provided you copy the keys into your /config folder
Since I’m running HAOS the /config is shared into the container the SSH extension is running in, so while I was creating a symlink to the ~/.ssh folder from /config, the files weren’t accessible to HAOS.