Wake on LAN switch turn_off shell_command not working

Hi,

I configured 3 switches to turn on 3 NAS devices. That part works just fine.
But the shell_command to turn off the NAS devices doesn’t work.
The problem I have with this documentation is:

  1. On the server , log in as the user account Home Assistant is running under.

I’m running Hass.io so I can only ssl as root.
I generated the private keys and I can run the ssh command just fine logged in as root.

ssh [email protected] /sbin/poweroff

But when pressing the switch nothing happens and I get this error message in the log file:

Error running command: `ssh [email protected] /sbin/poweroff`, return code: 255
NoneType: None

This is exactly the same error as this guy has. But I don’t understand what he did to fix it.

Take the backtick off the end of the command. That was the solution for using ssh automations.

Also, you should make sure you put the keyfile someplace like /config where it’ll persist since Hass.IO is containerized, everytime you upgrade it’ll go away. Then your ssh command would look like this:

ssh -i "/config/privatekeyfile" -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no [email protected] "/sbin/poweroff"

Hope that helps. Smashed my head against for a while before I figured that out.

1 Like

I had no backtick in the command. That was a quote from the log-file.

I stored the keyfile in the config folder and copied your exact ssh command.
Works perfectly!

Thank you,

J

Awesome, I’m glad I could help!