I’m creating an automation that shuts down a remote Ubuntu server using a SSH command. I have read many other topics here with seems to have the same issue, but the solution doesn’t work for me.
This command is working from the terminal, but not in Home Assistant: ssh user@host sudo /sbin/shutdown -h now
When I use the switch I get this error in Home Assistant: ERROR (SyncWorker_1) [homeassistant.components.command_line.switch] Command failed: ssh user@ubuntu sudo /sbin/shutdown -h now
In Ubuntu I see the following in /var/log/auth.log: ubuntu sshd[1290]: Connection closed by 192.168.2.64 port 39888 [preauth]
Home Assistant is running as root and I log in to Ubuntu with user.
I added “PermitRootLogin yes” into “/etc/ssh/sshd_config” and set a password for root user on Ubuntu.
Good solution, I have just one small change for my config - I had to chmod the key to 600 and I didn’t need the UserKnownHostsFile flag. Also, I don’t know if this is always the case, but I had to restart core for my yaml changes to take effect. Thanks!