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.
OK, that would be another way. But you can use remote ssh for not only shutting down the host but for any other host command, like restarting processes or other containers etc. So it might still be helpful.
BTW: I think neither. The issues here are coming from the fact that you have a very special use case and that HA is running in a container so it has very limited access to the resources on the host. Because of that we have to used ssh and certificates. So at the end, security is making this more complicated.
Crazy, that I am already, two days on this dopey problem, later I’ll be able to place the small no fan Zotac PC in a normal room that doesn’t get like a sauna
I use smart plugs for many things now, my cable/fiber routeur, base station for my Wyze camera setups, I can boot all of these from may other home, sometimes saving me having to drive 400km just to switch of and back on a plug
OK, I just remembered that you can shutdown the host from within HA. And in fact there is a service called hassio.host_shutdown
So all you need to do is to call this service either from the developer tools or from an automation.
Very simple.
Yes it should work. You can simply try develper tools->services search for hassio.host_shutdown and execute it. It will not work if the HA host is also virtalized like on Proxmox etc.