Skip to content
Home ยป How to Protect the Linux Server From an Accidental Reboot?

How to Protect the Linux Server From an Accidental Reboot?

As a Sysadmin, accessing a Linux server is a normal daily activity. But sometimes we accidentally make mistakes rebooting or shutting down the production server, causing the server to be inaccessible. Therefore, we need a tool to confirm if someone reboots or shuts down a Linux server.

 

Problem

How to protect the Linux server from an accidental reboot or shutdown?

 

Solution

In the Debian/Ubuntu distribution, the molly-guard tool can be used to protect the Linux server from an accidental reboot or shutdown. Use the two commands below to install molly-guard:

sudo apt update
sudo apt-get install molly-guard

 

After that, try to reboot the server, and there should be a notification like the image below:

A notification appears when trying to reboot the server

 

Someone who wants to reboot the server must write the server’s hostname. If the nameserver does not match the hostname on the server, the reboot process will not be continued, but if it matches the hostname on the server, the reboot process will be continued.

protect the Linux server from an accidental reboot
Try to reboot the server

 

This is very useful if the sysadmin accidentally types the reboot command on the server. However, this tool not only protects the server from the reboot command, but also other commands such as the poweroff, shutdown, coldreboot, pm-hibernate, pm-suspend, and pm-suspend-hybrid commands.

protect the Linux server from an accidental reboot
Try to turn off the server

 

Note

Keep in mind that this molly-guard tool can only work in the Debian/Ubuntu distribution and its derivatives, and this tool only works on SSH connections. If you access the Linux server without an SSH connection, for example, by directly connecting the keyboard to the Linux server, this tool will not work, so if you run the reboot command, the Linux server will immediately reboot.

 

References

manpages.ubuntu.com
launchpad.net
techbits.io

image_pdfimage_print
Visited 19 times, 1 visit(s) today
Tags:

Leave a Reply

Your email address will not be published. Required fields are marked *