0

I have 3 servers, one Qnap NAS and 2 Rpi3 that controls video surveillance, some basic domotics and so one.

I have just configured one server to monitor the UPS in order to be able to realise when it is the time to shutdown the servers because the UPS battery is running out.

My questions is simple: is there a way to send a shutdown command to servers without logging in through SSH?

I would like for the server that monitors the UPS to send, when needed, the shutdown to the other two servers without logging in.

Is it possible? Any protocol or anyhow else?

Thanks for helping, Daniele

Daniele
  • 15
  • An unauthenticated shutdown signal would be quite the lovely security hole. Imagine the malicious and nefarious applications.... – user535733 Nov 17 '17 at 15:06

2 Answers2

1

In my opinion ssh is the best way to do it. You can set it up so that you don't have to send a password at the login time. You can copy the local ssh key to the server so that when you send the ssh command there is no password required. NOTE: This works with any login on the remote host including root.

ssh-copy-id user@server

You would change user in the above command to whatever user can perform the shutdown. To do root it would be ssh-copy-id root@server.

When the ssh copy is complete, then you should be able to send the commands without a login prompting for a password.

Then in your script or what ever sends the command to the remote server it would look like so:

ssh root@server 'shutdown -h now'

There would be no password required and the server would shutdown.

Hope this helps!

Terrance
  • 41,612
  • 7
  • 124
  • 183
0

You could (it's a simple matter of Perl programming) write a Perl script to listen to a specific port, and upon receiving the right message, do the shutdown. Begin with the examples in the "Programming Perl" book (the Camel Book!) see Chapter 15.

waltinator
  • 36,399