pipelight/boulette: Prevents you from accidentally shutting down remote hosts!

It’s night. 🥱
You finish your evening coding session by typing shutdown -h now
in a terminal.
But nothing happens.
Because the terminal is wrong.
And suddenly your production server is unreachable.
Protect yourself from yourself. Get on the boulette train!
Boulette prevents you from accidentally shutting down remote hosts
by raising a warning prompt on dangerous commands. The prompt simply asks for user confirmation, and can also execute a challenge resolution to decide whether to continue (or abort) the command.
Prefix a critical command with boulette
and a confirmation prompt will appear.
boulette "shutdown -h now"
Create an alias to replace the command with can’t resist the boulette one. See the Write aliases section.
And then safe to use shutdown
😌.
To execute the given command you can choose between several challenges to solve:
-
QUESTIONSwhich is the default (
--challenge ask
). You must type ‘y’ or ‘n’ to continue executing the commande. -
hostnameable to
--challenge hostname
. You must type the host name to continue executing the command. -
numberswith
--challenge numbers
You need to type a random 6 number sequence to continue executing the command. -
characterswith
--challenge chars
You must type a random 6 character string (Lower case ‘a’ to ‘z’ (az)) to continue command execution.
Boulette confirmation prompt can be triggered internally ssh session only thanks for --ssh-only
option.
When aliasing a command
with boulette
typing
will be executed transparently in a local terminal, and will only raise a prompt when executed from within an ssh session.
alias off='boulette "shutdown -h now"' --ssh-only
The idea is to execute a prompt on your most sensitive commands. We can do this by creating aliases to those commands and prefixing them with boulette.
For example, setting the following alias,
alias off='boulette "shutdown -h now"' --ssh-only
will prompt you whenever you type shutdown -h now
.
Here are the one-liners I use all the time.
alias off='boulette "shutdown -h now" --ssh-only --challenge hostname'
alias sus='boulette "systemctl suspend" --ssh-only --challenge hostname'
alias reboot='boulette reboot --ssh-only --challenge hostname'
You can also enable boulette on a command and each of its subcommands.
Let’s say you want to protect yourself from shutdown
command ant each of its options. In this way shutdown -r
, shutdown -h now
and some will also raise a warning.
Create a shell function to wrap the command call.
shutdown () {
boulette "shutdown $argv" --ssh-only --challenge hostname
}
function shutdown;
boulette "shutdown $argv" --ssh-only --challenge hostname
end
with freight:
cargo install --git https://github.com/pipelight/boulette
with nix(fragments):
nix-shell -p https://github.com/pipelight/boulette
You can display a useful help message with a few examples.
This is very inspired Molly-guard.
https://opengraph.githubassets.com/4e66d5383ab54f162be797dd2ad6441f6ad2656e3b0eff74a173af0e31eac550/pipelight/boulette
2025-01-10 14:13:00