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.
Requirements
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.
Instructions
- In a remote terminal session to OctoPrint:
ssh-keygen -t rsa -b 2048 # Press Enter for each of the prompts
ssh-copy-id pi@pisense.local # Substitute for the hostname of the remote Raspi
ssh -t pi@pisense.local "ls" # Practice a test command (no pw required)
- In a web session with OctoPrint, Settings -> Gcode System Commands -> +
OCTO900
-> /usr/bin/ssh -t pi@pisense.local "sudo poweroff"
Press Save
to save the setting.
- Back in the remote shell to the OctoPrint server:
nano ~/.octoprint/config.yaml
Edit/add the controls
section:
controls:
- children:
- command: OCTO900
name: PiSense OFF
name: Custom Events
type: section
Restart OctoPrint. Note the new section and button on the Control
tab.
Review
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.