Reboot/shutdown client from script


Server is running Debian 10, all clients are running debian/raspbian.
All clients have server(s)’ public key in their ssh authorized_keys file.

I’d like to be able to call a OS shell script on the gateway to reboot or shutdown the clients.

Sometimes the client will not be operational (raspberry pi3) if it reboots faster than the server. I’m using and a standalone jre for these.

Ideally, a tag change script on the gateway would watch for a memory tag (say, RebootGuests) and would trigger /root/ on the gateway.

/root/ would contain the following:

ssh user@client1 '/sbin/reboot'
ssh user@client2 '/sbin/reboot'

Right now I can’t get /root/ to fire from the gateway.

Is there a way to do this?

I’m not sure about your specific request, but look into Ansible. I have about 100 raspberry pis that run ignition clients. The RPis are setup to autorun the ignition client on boot up. With a single command I can reboot or shutdown all, or a subset, of the Pis. All of my Pis run on a PoE switch. If you shut the Pis down and need to turn them on, just reboot the switch.

Are you sure Ignition is running as root? I usually use the zip for custom installs, but I thought the regular installer set up a service user (“ignition”) by default. If so, you need that ssh identity in the ignition user’s ~/.ssh folder.

Currently, the script /root/ just does contains


I should see this when logged in via ssh to the server.
It never seems to get called from Ignition via the gateway tag change script method.

I can’t run this from a client, as they are view only (no mouse / keyboard), and may not be running the software.

Basically I can’t seem to find a way to run a gateway shell script from within Ignition…

Show your script.

Consider trying to directly run /usr/bin/wall from the script, for starters.

Ok, I just changed this. Also forgot to save before testing, D’oh!

It appears to be working with the wall command. I’ll figure out ansible or some other method to do a shell reboot on the clients.

Thanks for all the help.

I ssh into the clients using sshpass

This is a sample script of what I use to reboot a set of Pis upon a gateway start. This is useful in the instance of upgrading a gateway, as the 32 bit clients don’t gracefully recover.

import os
import sys

ipList = [
for ip in ipList:
	call = 'sshpass -p supersecretpassword ssh piuser@%s sudo reboot' % ip
	print call
1 Like

Ahhhhgg! No, just no.

Jordan, you really need to learn to use public/private keys in SSH. And in this case, use a dedicated reboot key where the RPis constrain the key to only execute the reboot.