Comment Re:Or shut it down. (Score 2, Informative) 347
You might be interested in molly-guard (available in Debian/Ubuntu, and presumably others):
The package installs a shell script that overrides the existing shutdown/reboot/halt/poweroff commands and first runs a set of scripts, which all have to exit
successfully, before molly-guard invokes the real command.
One of the scripts checks for existing SSH sessions. If any of the four commands are called interactively over an SSH session, the shell script prompts you to enter the name of the host you wish to shut down. This should adequately prevent you from accidental shutdowns and reboots.
This shell script passes through the commands to the respective binaries in
22:56:13 rock:~ > sudo shutdown -r 5
W: molly-guard: SSH session detected!
Please type in hostname of the machine to shutdown: box
Good thing I asked; I won't shutdown rock
W: aborting shutdown due to 30-query-hostname exiting with code 1.
(I only have it installed on my server, so getting the question is enough to make me hit ^C. Also, my prompt is yellow on my home PC, red on my work PC, cyan on servers, and includes the hostname, so I'd need to be really tired to make a mistake.)