Command Line Switch

Hello all,

can I use the Command Line Switch to ssh into a second rpi to stop and start a service?

Or is there maybe a different comonent which support this?

Daranto

1 Like

You’ll want to have SSH keys set up from your HASS pi, but I don’t see a reason this wouldn’t work.

http://www.linuxproblem.org/art_9.html

Use like:
ssh username@other-host 'sudo service whatever stop/start'

Good luck!

thanks for the info.

here is my config:

- platform: command_line
  switches:
    reboot_hyperion:
      command_on: "ssh [email protected] reboot"
      command_off: "ssh [email protected] reboot"

When I use the switch I get the following error:

homeassistant.components.switch.command_line: Command failed: ssh [email protected] reboot

From the first pi its possible for me to ssh into the second one without any password. I also tried a local command. The same error appears.

Maybe someone know whats wrong with the switch.

Daranto

You’ll need to change it to:

- platform: command_line
  switches:
    reboot_hyperion:
      command_on: "ssh [email protected] 'reboot'"
      command_off: "ssh [email protected] 'reboot'"

Also, depending on who HASS is running as, you might need to specify the key file for login. You can do so with the -i flag:

ssh -i /home/user/.ssh/id_rsa

http://www.shellhacks.com/en/Running-Commands-on-a-Remote-Linux-Server-over-SSH

thx it works now.