deniz.in

Markets

Weather

Loading weather

· via dev.to (home feed)

Brute-forced SSH turned a VPS into a crypto miner: a two-hour cleanup and hardening walkthrough

A developer's unresponsive VPS was actually running a crypto miner planted via a brute-forced SSH password login, and the cleanup doubles as a practical hardening checklist for self-hosters.

Brute-forced SSH turned a VPS into a crypto miner: a two-hour cleanup and hardening walkthrough

What happened

A first-person incident report published on dev.to walks through a virtual private server compromise that began not with a security alert but with silence. According to the author, Igor Rakov, the AI agent that runs most of the infrastructure on his VPS simply stopped responding. Once he opened a terminal, top showed a process named /tmp/mysql consuming 381% CPU and 2.4 GB of RAM. The name was camouflage: the binary was a cryptocurrency miner, planted after an attacker brute-forced an SSH login.

How the server was exposed

The write-up identifies three misconfigurations that together amounted to an open door: SSH permitted root logins (PermitRootLogin yes), password authentication was switched on, and nothing was in place to throttle brute-force attempts. The server's logs showed more than 30 failed SSH logins per hour arriving from a rotating pool of IP addresses. Sooner or later one of those guesses landed on a weak credential, and the miner came in with it.

The remediation, step by step

The cleanup ran in five moves, all documented in the post:

  • Kill the mining process and delete the /tmp/mysql binary.
  • Restrict SSH to key-based access by setting PermitRootLogin prohibit-password and PasswordAuthentication no. With passwords out of the picture, there is nothing left to guess.
  • Install fail2ban, lengthening bans from one hour to 24 hours and adding a recidive jail that locks out repeat offenders for a week.
  • Run rkhunter, a rootkit scanner. Its database covers 498 rootkits; the scan found none, suggesting the miner was the only payload on the box.
  • Turn on unattended upgrades so that future SSH or kernel vulnerabilities patch themselves rather than waiting for someone to notice.

Before and after

The post includes hard numbers on the recovery. Before the fix, the CPU had 0% idle time, the load average sat at 6.06 and only 1.5 GB of RAM was free. After hardening, CPU idle reached 79%, the load average fell to 1.54 and free memory climbed to 3.9 GB.

The hostile traffic itself did not let up. In the week following the cleanup, fail2ban blocked 44 IP addresses and logged 15,678 failed SSH attempts. In the author's telling, the attacks kept coming after hardening; they simply stopped being dangerous.

Why it matters

This incident is a compact, reproducible checklist rather than an exotic exploit. Nothing here involved a zero-day: the attacker walked through a password-protected root account on an internet-facing machine, a configuration common on cheap cloud instances. Two details stand out. First, the malware hid behind a plausible process name, so anyone triaging a slow server should check where a binary actually lives rather than trusting its label, since a legitimate MySQL install does not run out of /tmp. Second, the entire remediation took roughly two hours, per the author, and every measure applied — key-only SSH, fail2ban, automated patching, a rootkit scan — is standard and low-cost. For self-hosters running services on budget VPS plans, the lesson is straightforward: treat the server as under constant scan from the instant it comes online, and close the password door before something finds it.

  • #ssh
  • #vps
  • #security
  • #crypto-mining
  • #fail2ban

Related posts