I’ve installed MobaSSH on my Windows PC and it’s running as a service at x.x.x.150
I have the SSH server plugin running and configured on my HA install on my Rpi 3 B+ at x.x.x.12
Logged into HASS.IO as root I have generated my RSA keys and saved the file to/config/id_rsa
I’ve copied my public key to my windows machine and verified I can SSH to that machine from my Rpi with [email protected] without being challenged for a password.
while logged in as that user, I have verified I can successfully execute ‘shutdown -r now’
However, when I try and run this same command from within Home Assistant, I get a 255/timeout error.
I have my shell command saved in shell_command.yaml and I can access it as a service command in the dev section of the UI. My shell command is…
Strange I had the same symptoms some time ago. I ended up sshing in to hassio host and then running a shell in the home assistant docker container it’s self. From there I tested my ssh command. Maybe you can do the same. What happened for me is it asked for confirmation that the host key was correct. Adding the above switch prevented this.
Does it make a difference that Home Assistant is trying to run the command rather than root on the Pi? Is there a possibility that a key generated by root would be no good when used by another system user - or does Home Assistant run as root already?
I’m not sure tbh. I don’t remember how I generated my key as it was so long ago. When you say you are sshing in as root, do you mean to port 22 or port 22222 of the hassio device? If you want to really test as the same context as home assistant you need to ssh to port 22222 (sd card will need keys on it) you can only auth to 22222 with keys and not password. Once you are in here you can use docker to run a shell in the home assistant container and test.
I ssh’d into port 22 as root when I generated my keys. I don’t have keys on my SD card for HA.
I removed -l from my command and received better info back from the Windows PC and it is definitely a permissions problem, executing this command from HA is not the same as executing from root it seems.
Command executed: ssh -o StrictHostKeyChecking=no -i /config/id_rsa [email protected] "shutdown -r now": 255
Warning: Permanently added 'x.x.x.150' (ECDSA) to the list of known hosts.
Permission denied, please try again.
Permission denied, please try again.
[email protected]: Permission denied (publickey,password,keyboard-interactive).
This looks almost perfect for what I am trying to do, but can I do a restart with this? I don’t want to shutdown the machine, I want to perform a full restart with this command.
I don’t believe the addon supports this, sorry. You can let it shutdown and then start back up with the WOL switch but I don’t believe sending a restart command is available.
I previously had a setup where this was possible. Basically I had a command line script that created a ssh connection from the HA container to the host system and then called a “net rpc shutdown…” command directed at the Windows machine. The ssh part was only necessary because the net command was not available from within the HA container.
After chatting with a mod in Discord today, we came up with a modified version of RPC shutdown which instead sends a restart command, works great. If anyone wants a copy just let me know.
Trying to get this for you guys, but I can’t remember which directory it’s stored in on my install. Where do you put local addons so they show in the addon section of the admin area? DOH!!