I've got two additional Raspberry Pi computers which I use in conjunction with my OctoPrint installation. Since I needed the ability to remotely shutdown one of them from OctoPrint, I thought I'd show how.
In order to do this, it will be useful to install the Gcode System Commands plugin in order to associate a named GCODE command to a command line.
- In a remote terminal session to OctoPrint:
ssh-keygen -t rsa -b 2048 # Press Enter for each of the prompts ssh-copy-id firstname.lastname@example.org # Substitute for the hostname of the remote Raspi ssh -t email@example.com "ls" # Practice a test command (no pw required)
- In a web session with OctoPrint, Settings -> Gcode System Commands -> +
/usr/bin/ssh -t firstname.lastname@example.org "sudo poweroff"
Save to save the setting.
- Back in the remote shell to the OctoPrint server:
controls: - children: - command: OCTO900 name: PiSense OFF name: Custom Events type: section
Restart OctoPrint. Note the new section and button on the
Using a shared key, the OctoPrint-related Raspberry can now run remote commands on the second Raspberry Pi as controlled by a button on the interface.