Not shutting down the wrong machine

Here is where you can post tips and tricks to share with other users of MX. Do not ask for help in this Forum.
Message
Author
User avatar
b3ta
Posts: 72
Joined: Mon Aug 20, 2018 4:34 am

Not shutting down the wrong machine

#1 Post by b3ta »

I expect quite a few of the users on this forum have more than one box, and for those of us who log in via SSH to do things somewhere else, a momentary lapse of concentration can be quite problematic if you believe you're shutting down one machine while you're actually on another.

I've been using the "molly-guard" package for absolute ages and it's saved me a few times. It works with SSH (IIRC, also with Mosh), as this example demonstrates:

Code: Select all

root@server:~# shutdown -hP now
W: molly-guard: SSH session detected!
Please type in hostname of the machine to shutdown: Aargh!
Good thing I asked; I won't shutdown server ...
W: aborting shutdown due to 30-query-hostname exiting with code 1.
root@server:~# 
The story behind it is fascinating. Read one of those claiming to be the truth here: http://catb.org/jargon/html/M/molly-guard.html

Two more points:
  1. Its man page notes some important caveats. While they don't mention it by name, tmux is one of them. I didn't RTFM and discovered this last week. While I did intend to reboot the machine, it was a surprise, and led me to write this tip.
  2. The man page doesn't mention it, but the file "/etc/molly-guard/rc" has an "ALWAYS_QUERY_HOSTNAME" setting, which I feel should be mandatory on any important machine.

User avatar
CharlesV
Global Moderator
Posts: 7653
Joined: Sun Jul 07, 2019 5:11 pm

Re: Not shutting down the wrong machine

#2 Post by CharlesV »

This is excellent! I tried this a few days back and it worked perfectly for me!
*QSI = Quick System Info from menu (Copy for Forum)
*MXPI = MX Package Installer
*Please check the solved checkbox on the post that solved it.
*Linux -This is the way!

User avatar
DukeComposed
Posts: 1454
Joined: Thu Mar 16, 2023 1:57 pm

Re: Not shutting down the wrong machine

#3 Post by DukeComposed »

b3ta wrote: Tue Jul 08, 2025 8:57 am I've been using the "molly-guard" package for absolute ages and it's saved me a few times. It works with SSH
Fun fact: Molly-guards are named molly-guards because a programmer's young daughter hit the big red kill switch on an IBM 4341 at the University of Illinois twice in one day. They had to improvise a little plastic shield to keep her, or anyone else, from unintentionally pushing the kill switch. In retrospect, I have to wonder why IBM didn't think of this before they started selling machines with big red kill switches. You can probably guess the daughter's name.

Post Reply

Return to “Tips & Tricks by users (not for help)”