gitmyhub

takeover.sh

Shell ★ 7.3k updated 4y ago

Wipe and reinstall a running Linux system via SSH, without rebooting. You know you want to.

A shell script that completely replaces a running Linux server's operating system over SSH, with no reboot and no physical access, by loading a rescue environment into RAM and freeing the disk for reformatting.

ShellLinuxBusyBoxsetup: hardcomplexity 5/5

takeover.sh is a shell script that lets a Linux administrator completely replace a running server's operating system over a remote SSH connection, without rebooting or touching a physical keyboard. It targets situations where you have remote access to a machine but no way to insert a USB drive or visit the data center.

The process works by loading a rescue environment (a minimal Linux system) entirely into the server's memory. The script then transfers the running system's core process over to the in-memory version, freeing up the original disk. Once the original disk is unmounted, you can repartition it, reformat it, and install a completely different Linux distribution, all while the server stays reachable over SSH.

The README is direct about the danger: if anything goes wrong during the takeover, the server will very likely crash and require physical access to recover. The author explicitly says not to use the script on any machine you care about and strongly recommends testing in a virtual machine first. There is no undo step, no safe exit back to the original system, and the README deliberately withholds copy-paste instructions because it is written only for people who already understand exactly what each step does.

The script supports Linux systems using sysvinit or systemd as their process manager. Running it requires a statically linked copy of busybox (a compact set of Unix utilities), a compiled helper program called fakeinit, and a rescue environment small enough to fit in the server's available RAM.

Where it fits