Sorry my fault. Create 1 user, eg. homeassistant or use an existing one and add it to the sudo group and sudoers file. Then use this user for the ssh command. For user homeassistant you would use:
So it seems that the host is not accepting the ssh connection. Can you please enable debugging for shell_command in configuration.yaml, restart HA, try again and check the logs.
logger:
default: critical #or whatever you use
logs:
homeassistant.components.shell_command: debug
In the new /home/trevor/.ssl folder I copied the contents of the id_rsa.pub onto the authorized_keys file
Then added to /usr/share/hassio/ssl (the ssl folder existed already)
both the id_rsa.pub & id_rsa files as not sure which one goes where
rebooted everything
Now I get a error 2 and no longer an error 225
Error running command: ssh -i /usr/share/hassio/ssh/id_rsa ssh [email protected] sudo shutdown -h now', return code: 2
If I now run the
sudo systemctl status ssh
I no longer get the
Failed password for homeassistant from 192…
Follow this. The process is to generate the keys within the HA docker container and then copy them to the host into the correct directory. I hope I didn’t miss anthing. My system is different so I cannot try every step myself. But this should work because I used it sometime in the past.
1. Create user homeassistant if not already done
2. Add homeassistant to sudo group: $ sudo usermod -aG sudo homeassistant
3. Modify the host sudoers file to allow the homeassistant user to skip typing the password when connecting via ssh and running sudo.
$ sudo visudo
Add the following 2 lines to the user privilege section:
homeassistant ALL=(ALL) NOPASSWD:ALL
%sudo ALL=(ALL) NOPASSWD:ALL
4. Save the file.
5. Login to the home-assistant container (note: home-assistant is the container name. check if your container has the same name or change it in the following command. Check with “docker ps” command for the right name.
$ sudo docker exec -it home-assistant /bin/bash
So now you are logged into the HA OS. Note you could also install the Advanced SSH & Web Terminal add-on instead, open a terminal and execute the following steps. But this is faster, no add-on needed.
6. Generate sshkey
$ ssh-keygen -t rsa (press enter, enter, enter)
7. Copy the sshkey to your host
$ ssh-copy-id [email protected] (type password when prompted)
8. Test ssh connection with sudo:
ssh [email protected]
Hopefully you are now logged into the host OS. Please say yes!
If this works then your shell_command should also work.
Seems like shutting the device down that runs your HA server would be the last thing anyone would want to do. Have all additional cooling/ventilation efforts failed? If you remotely shut it down when it’s overheating, how do you turn it back on? manually? You cant send a similar command to turn it on obviously.