Ransomware on a Linux server: containment, recovery and the legal clock (EU, US, Canada)
Ransomware on Linux usually arrives through an exposed service, a stolen credential or a vulnerable web application. The priorities are to stop it spreading, to protect your backups, and to restore from a source you trust.
Isolate the machine and its backups
Disconnect the server from the network at the provider and from other servers. Make sure backup storage is not mounted or reachable from it, because ransomware targets backups too.
mount | grep -Ei 'nfs|cifs|fuse|backup' sudo umount /mnt/backup # if mountedPreserve evidence
Take a disk snapshot and note the time. Keep the ransom note and an encrypted sample file.
ls -la --time=ctime / | head find / -maxdepth 3 -type f \( -iname '*README*' -o -iname '*DECRYPT*' \) -mtime -2 2>/dev/null | headIdentify what happened and how
Which files are encrypted, from when, and which account or service ran the process.
sudo find /var /home -type f -mtime -1 | head -n 20 last -a | head sudo journalctl --since '2 days ago' -p warning | tail -n 50Check your backups before restoring
Restore a copy to a clean machine and confirm it opens, and that its date is before the first encrypted file.
Rebuild and restore on a clean server
Install a new server, apply every update, close the entry point, then restore data. Do not reuse the infected disk.
Know the notification deadlines
In the EU, a personal data breach must be reported to the supervisory authority within 72 hours of becoming aware of it, unless it is unlikely to risk people. In Canada, PIPEDA requires reporting breaches with a real risk of significant harm. In the US, every state has its own breach law and some sectors have federal rules. Talk to your lawyer and, if you have one, your cyber insurer early.
Common mistakes
- Paying quickly: it does not guarantee decryption and funds further attacks.
- Restoring over the infected server and getting encrypted again.
- Keeping backups on a share mounted read-write from the same server.
How to undo it
Recovery is not reversible in place: the safe path is a rebuild. Keep the infected snapshot until the investigation and any legal process finish.
Sources
Commands are for Debian and Ubuntu unless noted. Test on a copy first and keep a backup: you are responsible for changes on your own systems.