Hi. I’m also trying to call SH scripts from Home Assistant (HASSIO in docker).
In my case I gave up running the scripts on my HASSIO host (Ubuntu virtual machine)
From my docker container I run the following command which connects to another server, referencing a private key and then run a script on it.
ssh -i /config/.ssh/id_rsa [email protected] sh /home/km/testing.sh
I’m no longer prompted for a password when I log into docker as root and run the above command since I copied the private key to /config directory. Everything works great, until I reboot.
After reboot I get same error as you, 255.
The problem now is known_hosts. Post reboot, the first time I tried to run the command from shell as root in docker I was prompted to add target machine, 192,168.1.200 to known_hosts. After I type Yes and added it to known hosts I was able to run the command above perfectly. From within home assistant I can call on the shell command! It’s awesome, until I restart and have to do it again.
Anyway, I think we need to figure out a way to keep the known_hosts file persistent. I believe it is getting wiped out periodically from restarting.
You can confirm this by logging into your docker container as root and trying to connect the same way. Once you add the host to known_hosts you should be fine.
I checked the SSH options hoping there is way to reference a specific known_hosts file but came up empty handed.
Edit: I got it! Here is the command I use:
ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i /config/.ssh/id_rsa [email protected] sh /home/km/testing.sh
So, in summary - I have this command setup as a shell_command in Home Assistant. I can reboot Home Assistant, the docker container, and system running docker and it works on every try!!