Ransomware doesn't ask permission. It lands through a compromised credential, an unpatched exploit, or a phishing email that reaches someone with SSH keys. Once inside, it spreads laterally, encrypts everything it can reach, and leaves you staring at a ransom note. The question isn't whether you'll be targeted—it's whether your defenses will hold when the attack comes.
I've worked through the aftermath enough times to know that most breaches exploit the same gaps: backups stored where the attacker can reach them, overly permissive access, and blind spots in monitoring. The good news is that ransomware follows predictable patterns. Layer your defenses correctly and you catch it before encryption starts.
Backup isolation comes first
Your backups are the attacker's primary target. If ransomware can encrypt your production data and your backups, you have no recovery option except paying the ransom—and even then, there's no guarantee you get your data back.
Immutable backups solve this. Once written, they can't be modified or deleted until the retention period expires. Most backup solutions now support immutability through object lock policies or append-only modes. Enable it. Set retention windows based on your RPO requirements, typically seven to thirty days.
Air-gapped backups add another layer. An offline copy that's physically disconnected from the network can't be reached by network-based attacks. This doesn't mean tape drives in a closet—modern air gaps use automated systems that connect only during scheduled backup windows, then disconnect completely. For critical systems, keep at least one recent full backup offline.
Store backups in a separate account or tenant. If your production environment uses AWS, put backups in a different AWS account with its own credentials. If an attacker compromises your main account, they can't pivot to the backup account without a second set of credentials. The same principle applies to Azure subscriptions, GCP projects, or any multi-tenant storage platform.
Never store backup credentials on the systems being backed up. I've seen incidents where attackers found Veeam credentials in a config file on the compromised server and used them to delete every backup repository. Store credentials in a secrets manager with strict access controls, or use service accounts with permission boundaries that prevent them from deleting backups.
Test restores regularly. A backup you can't restore is worthless. Schedule monthly or quarterly restore drills where you actually spin up a system from backup and verify functionality. Document the restore process so anyone on your team can execute it under pressure.
Lock down access paths
Ransomware needs a way in. The most common entry points are SSH, RDP, web application vulnerabilities, and compromised credentials.
Disable password authentication for SSH entirely. Use key-based authentication exclusively, and store private keys in hardware tokens or encrypted vaults. Set PasswordAuthentication no in /etc/ssh/sshd_config and restart the SSH service. For root access, set PermitRootLogin prohibit-password or disable it completely and require users to elevate with sudo.
# /etc/ssh/sshd_config hardening
PasswordAuthentication no
PermitRootLogin prohibit-password
PubkeyAuthentication yes
ChallengeResponseAuthentication no
UsePAM yes
ClientAliveInterval 300
ClientAliveCountMax 2
Limit SSH access by IP. If your team connects from known networks, restrict SSH to those CIDR blocks using firewall rules. For remote access from dynamic IPs, use a VPN or bastion host as a choke point. Tools like fail2ban add rate limiting and automatically block IPs after repeated failed attempts.
Implement certificate-based authentication for internal services. Short-lived certificates tied to user identity eliminate static credentials that can be stolen. Solutions like HashiCorp Vault, Teleport, or Boundary automate certificate issuance and enforce access policies centrally.
Apply the principle of least privilege everywhere. Service accounts should have only the permissions they need to function, nothing more. A web application database user doesn't need DROP TABLE privileges. A backup agent doesn't need the ability to delete snapshots. Review permissions quarterly and prune anything excessive.
For RDP and Windows servers, require network-level authentication and disable local administrator accounts where possible. Use domain accounts with time-limited group membership, and enable RDP Restricted Admin mode to prevent credential caching.
Monitor for early warning signs
Ransomware leaves traces before it starts encrypting. File system monitoring, process behavior analysis, and log aggregation catch these traces if you're watching for them.
Watch for mass file modifications. Normal operations don't rename thousands of files in minutes. Tools like auditd on Linux or Windows Event Logs can track file access patterns. Set alerts for any process that modifies more than a threshold number of files in a short window—say, a hundred files in five minutes.
# auditd rule to watch sensitive directories
auditctl -w /var/www -p wa -k webroot_changes
auditctl -w /home -p wa -k home_changes
Monitor process creation and execution chains. Ransomware often spawns unusual processes or uses legitimate tools in abnormal ways—PowerShell launching encoded commands, wmic executing remote scripts, or compression utilities called by a web server process. EDR solutions automate this detection, but even manual log review can catch obvious anomalies.
Track authentication events, especially failed logins and privilege escalations. A spike in failed SSH attempts or repeated sudo failures signals someone probing for access. Aggregate logs centrally using syslog, ELK stack, or a SIEM so you can correlate events across systems.
Set up file integrity monitoring for critical system files and configurations. Tools like AIDE or Tripwire generate checksums of known-good file states and alert when anything changes. If /etc/passwd or /bin/bash gets modified unexpectedly, you know something's wrong before ransomware runs.
Monitor network traffic for lateral movement. Attackers rarely stay on the entry point—they spread to other systems. Watch for SMB connections between servers that don't normally communicate, or SSH sessions initiated from user workstations to production servers. Network segmentation and firewall logging make this visible.
Patch management isn't optional
Unpatched vulnerabilities are free entry points. Attackers scan the internet constantly for known CVEs, and exploitation tools are available within hours of disclosure.
Automate security updates where possible. For package-managed systems, enable unattended-upgrades on Debian/Ubuntu or dnf-automatic on RHEL/CentOS. Configure them to install security patches automatically while deferring major version upgrades for manual review.
# Enable unattended-upgrades on Ubuntu
apt install unattended-upgrades
dpkg-reconfigure --priority=low unattended-upgrades
For web applications and custom software, track dependencies and update them regularly. Outdated WordPress plugins, PHP libraries, or Node modules are common entry points. Use dependency scanning tools integrated into your CI/CD pipeline to catch vulnerabilities before deployment.
Maintain an inventory of installed software. You can't patch what you don't know about. Automated asset discovery tools or simple scripting can generate a list of running services, open ports, and installed packages across your fleet.
Establish a patch cadence. Critical vulnerabilities get emergency patches within hours or days. High-severity issues get patched within a week. Everything else follows a monthly maintenance window. Document exceptions for systems that can't be patched immediately and implement compensating controls—network isolation, WAF rules, or temporary service shutdowns.
Network segmentation limits blast radius
If ransomware breaches one system, it shouldn't reach everything else. Flat networks with no internal boundaries let attacks spread unchecked.
Segment your infrastructure into security zones. Put public-facing web servers in one zone, application servers in another, and databases in a third. Use firewalls to enforce strict rules about which zones can communicate. A web server should reach the application tier on specific ports only, and the app tier should reach the database tier, but nothing should initiate connections back toward the public zone.
Isolate management interfaces. SSH, RDP, and administrative panels should not be accessible from the same network as user traffic. Put management access on a separate VLAN or VPN that requires additional authentication.
Use micro-segmentation for critical systems. In a zero-trust model, every workload gets its own network identity and policy. Even within the same security zone, a compromised web server can't reach another web server unless explicitly permitted. This requires more setup—service meshes, software-defined networking, or host-based firewalls—but it dramatically reduces lateral movement.
Disable unnecessary network services. A server running Postfix for local mail delivery doesn't need to accept SMTP connections from the internet. Bind services to localhost where possible, and firewall everything else.
Incident response planning before the incident
When ransomware hits, you don't have time to figure out who does what. A documented incident response plan with clear roles and pre-tested procedures is the difference between controlled recovery and chaos.
Define your response team. Who gets alerted first? Who has authority to shut down systems? Who communicates with customers, management, and possibly law enforcement? Write it down and make sure everyone knows their role.
Prepare isolation playbooks. In the first minutes of an attack, you may need to disconnect compromised systems from the network to stop the spread. Document exactly which firewall rules to apply, which VLANs to disable, or which VMs to power off. Automate where possible so a single command can isolate an entire zone.
Maintain a clean recovery environment. If your entire production network is compromised, you need a separate, known-good environment to rebuild from. This could be a segregated set of VMs, a secondary cloud account, or physical hardware that's never networked with production. Keep installation media, config templates, and documentation accessible without relying on potentially compromised systems.
Practice your plan with tabletop exercises. Walk through a simulated ransomware scenario quarterly: someone reports that files are being encrypted, what happens next? Where are the gaps? What assumptions were wrong? Adjust the plan based on what you learn.
Establish communication channels that don't depend on your production infrastructure. If your email and Slack are on compromised servers, how do you coordinate? Keep a contact list of cell phone numbers, and set up a backup communication method—a personal messaging app, conference bridge, or even a dedicated Discord server.
Detection tools that actually help
Commercial EDR and SIEM solutions provide the most complete coverage, but smaller operations can build effective detection with open-source tools.
OSSEC or Wazuh offer file integrity monitoring, log analysis, and rootkit detection across Linux and Windows. They're free, actively maintained, and can alert on suspicious patterns like rapid file encryption or unauthorized process execution.
Suricata or Snort provide network intrusion detection. They match traffic against known attack signatures and can flag lateral movement, exploit attempts, or command-and-control communication.
For centralized logging, the ELK stack (Elasticsearch, Logstash, Kibana) or Graylog aggregate logs from across your infrastructure and let you search, correlate, and visualize events. Set up saved searches and alerts for patterns like authentication failures, privilege escalations, or mass file operations.
ClamAV scans for malware signatures. It's not a complete endpoint protection solution, but scheduled scans of web roots and upload directories catch known malicious files before they execute.
Use these tools together. Log aggregation without alerting is just data storage. Intrusion detection without follow-up is noise. Build dashboards that surface actionable anomalies and integrate alerts into your on-call rotation.
The checklist that matters most
Ransomware defense is a checklist discipline. You don't need exotic tools or huge budgets, but you do need consistent execution across every system.
Immutable backups in a separate account, tested quarterly. Key-based SSH with IP restrictions and MFA where possible. Automated security patching with a documented exception process. File integrity monitoring and log aggregation with alerts configured. Network segmentation that prevents lateral movement. An incident response plan that your team has practiced.
The attacks will keep coming. What changes is whether they succeed.
