oh sorry you’re using the ssh addon. That will connect as its own container anyway.
I use quotes but I don’t think they are required anyway if you don’t have parameters.
oh sorry you’re using the ssh addon. That will connect as its own container anyway.
I use quotes but I don’t think they are required anyway if you don’t have parameters.
You may need this. The reason, I believe, is you haven’t accepted the host key while you did in the other container. and that will just wash away after a container restart.
ssh -i /config/ssh_keys/id_rsa -o 'StrictHostKeyChecking=no' [email protected] "sudo shutdown -h now"
essentially, this is happening when you execute this in the container I believe:
bash-5.1# ssh [email protected] "sudo shutdown -h now"
The authenticity of host '10.100.1.183 (10.100.1.183)' can't be established.
ED25519 key fingerprint is SHA256:sdfsadfasfasfasfas.
This key is not known by any other names
Are you sure you want to continue connecting (yes/no/[fingerprint])? ^C
and btw, you can drop the quotes and the script and probably even do this:
shutdown_imac_left: "ssh -i /config/ssh_keys/id_rsa -o StrictHostKeyChecking=no [email protected] sudo shutdown -h now"
The reason you had trouble with this earlier was the double quotes.
Man, you are a star! Thank you!!!
I had put so much effort and tests on this and nothing worked!.
I wasn’t aware of the StrictHostKeyChecking directiva.
As soon as I added it to the command it did worked!!!
THANK YOU so much
THANK YOU
ps Even though it works I get this at logs :
Logger: homeassistant.components.shell_command
Source: /usr/src/homeassistant/homeassistant/components/shell_command/__init__.py:115
Integration: Shell Command (documentation, issues)
First occurred: 9:10:02 PM (2 occurrences)
Last logged: 9:12:01 PM
Error running command: `/config/scripts/imac_shutdown_left.sh`, return code: 255
I know it’s nothing and I can ignore it, but can I do something and doesn’t show up at log files???
add a ‘exit 0’ at the end of the script. Since ssh is returning an exit code of 255 and it is the last command, its returning that to HA. Its either ssh or the remote script returning that 255. So just add a ‘exit 0’ to the end, and it will always return successful.