Exova Academy

Blog / Cybersecurity in the Age of AI

How to Detect a Crypto Miner on a Linux Server: Practical Guide

October 1, 2026 · 10 min read

To detect a crypto miner on a Linux server, four checks are enough in the vast majority of cases: find the process eating the CPU (top, ps), check its real binary in /proc, list outbound connections to mining pools (ss, lsof), then hunt down the persistence mechanisms (systemd services, timers, crontabs, SSH keys). A slow server with CPU at 100% for no business reason, a cloud bill that keeps climbing or an abuse notice from your hosting provider are the classic warning signs. This guide covers the commands, how to read their output, the right order for eradication and the prevention measures that matter.

The scenario is fictional: the server app01 (203.0.113.20) belonging to an imaginary small web agency. Every command is defensive and meant to be run on your own systems, with the necessary admin rights.

Detecting a crypto miner on a Linux server: the warning signs

This covert use of your resources has a name: cryptojacking. A cryptocurrency miner, most often a build of XMRig mining Monero, tries to use your computing power for as long as possible without being noticed. Its symptoms are therefore indirect:

  • A slow server with CPU at 100% around the clock, including at night, with no traffic spike or scheduled job to explain it.
  • A load average equal to or above the number of cores, continuously.
  • Fans or temperature rising on a physical server; a bill or overage alert on a cloud instance.
  • An abuse notice from your host for "mining activity" or connections to known pools.
  • Degraded business services: web timeouts, choppy audio on VoIP, queues getting longer.
  • Monitoring tools stopped or security agents uninstalled without anyone on your side doing it.

On app01, the alert came from monitoring: CPU at 98% since 3 a.m., even though the site gets almost no visitors at that hour.

Step 1: identify the suspicious process

The first command is uptime, then top sorted by CPU:

uptime
#  09:12:04 up 41 days,  2 users,  load average: 4.02, 4.01, 3.98
nproc
# 4
top -o %CPU -b -n 1 | head -15

A load of 4 on 4 cores, steady over 15 minutes, confirms continuous consumption. ps then gives a more precise view, with the parent, the user and the elapsed time:

ps -eo pid,ppid,user,%cpu,%mem,etime,cmd --sort=-%cpu | head -10
#   PID  PPID USER  %CPU %MEM   ELAPSED CMD
#  2381     1 root   389  2.1  06:11:52 [kswapd0]

Three anomalies stand out:

  • The name [kswapd0] mimics a kernel thread, but a real kernel thread has PID 2 (kthreadd) as its parent, not PID 1, and never uses 389% CPU.
  • The parent is systemd (PID 1): the process was most likely started by a service.
  • The elapsed time matches the moment the alert started.

The name shown by ps can be faked; the real binary can be read in /proc:

sudo ls -l /proc/2381/exe
# lrwxrwxrwx 1 root root 0 ... /proc/2381/exe -> /var/tmp/.font-unix/kswapd0 (deleted)
sudo cat /proc/2381/cmdline | tr '\0' ' '; echo
sudo ls -l /proc/2381/cwd

The (deleted) tag means the file was removed from disk after launch to make analysis harder. The binary can still be recovered as long as the process is running:

sudo cp /proc/2381/exe /root/evidence/kswapd0.bin
sha256sum /root/evidence/kswapd0.bin

Two other typical XMRig clues: arguments such as --donate-level or stratum+tcp://, and system settings tuned for the RandomX algorithm.

sysctl vm.nr_hugepages
# vm.nr_hugepages = 1280   (0 by default on most servers)
lsmod | grep -w msr

What if the process is invisible?

Some malware loads a library through /etc/ld.so.preload to hide from ps and top. A maxed-out CPU with no visible process is a strong signal. Check:

cat /etc/ld.so.preload 2>/dev/null
ls -d /proc/[0-9]* | wc -l
ps -e --no-headers | wc -l

A large, persistent gap between the two counts, or an ld.so.preload file you did not create, indicates the malware is hiding. At that point the system's own tools can no longer be trusted: a rebuild is the only safe option.

%% titre: How to track down a crypto miner
%% narration: In this diagram, we start from a maxed-out CPU, identify the process and its real binary, check its network connections, then look for its persistence and the entry point before deciding whether to clean up or rebuild.
flowchart TD
  A["Unexplained 100% CPU"] --> B["top and ps: suspicious process"]
  B --> C["/proc: real binary"]
  C --> D["ss and lsof: outbound connections"]
  D --> E["systemd, cron, SSH keys"]
  E --> F["Logs: entry point"]
  F --> G{"Root access obtained?"}
  G -- "yes" --> H["Rebuild"]
  G -- "no" --> I["Clean up under monitoring"]
How to track down a crypto miner

Step 2: check network connections

A miner has to talk to a mining pool to receive work and submit results. List established connections along with the owning process:

sudo ss -tnp state established
# 203.0.113.20:51844  198.51.100.77:3333  users:(("kswapd0",pid=2381,fd=12))

Ports 3333, 4444, 5555, 7777 and 14444 are heavily used by pools, but port 443 is used too in order to blend in: what matters is the combination "unknown process + permanent outbound connection", not the port alone.

sudo ss -tnp | grep -E ':(3333|4444|5555|7777|14444)\b'
sudo lsof -nP -p 2381 | grep -E 'IPv4|IPv6|REG'
sudo lsof -nP -i -sTCP:ESTABLISHED

lsof -p also shows the files the process has open: a config file (often JSON with pool or url fields) reveals the pool address and sometimes the attacker's wallet, which is useful for reporting.

Finally, look at recent DNS lookups if you run a local resolver with logging: queries to domains containing pool, xmr or mine are indicators worth keeping.

Step 3: hunt down persistence (systemd, crontab, SSH)

Killing the process is pointless if it restarts two minutes later. Miners almost always install several restart mechanisms.

systemd services and timers

systemctl list-units --type=service --state=running
systemctl list-unit-files --state=enabled | grep -v '@'
systemctl list-timers --all
sudo find /etc/systemd/system /lib/systemd/system -name '*.service' -mtime -30

On app01, a service with a plausible name shows up:

systemctl cat dbus-sync.service
# [Service]
# ExecStart=/var/tmp/.font-unix/kswapd0
# Restart=always
# [Install]
# WantedBy=multi-user.target

No package provides this service (dpkg -S or rpm -qf on the file returns nothing): it is malicious persistence. Restart=always explains why the process comes back after a plain kill.

Crontabs

sudo crontab -l -u root
for u in $(cut -d: -f1 /etc/passwd); do sudo crontab -l -u "$u" 2>/dev/null | sed "s/^/$u: /"; done
ls -la /etc/cron.d /etc/cron.hourly /etc/cron.daily /var/spool/cron/crontabs

A line that re-downloads a script from an external address every few minutes, or that relaunches a binary hidden in /tmp, /var/tmp or /dev/shm, is a telltale sign. Be suspicious of file names starting with a dot in /etc/cron.d.

Accounts, SSH keys and other footholds

sudo find / -xdev -name authorized_keys -exec ls -l {} \; -exec cat {} \;
awk -F: '$3 == 0 {print $1}' /etc/passwd
grep -E 'curl|wget|base64' /root/.bashrc /root/.profile /etc/rc.local 2>/dev/null
sudo find /tmp /var/tmp /dev/shm -type f -perm -u+x -ls
sudo lsattr -R /etc /root /var/tmp 2>/dev/null | grep -E '^[^ ]*i[^ ]* '

An unknown SSH key in authorized_keys, a second account with UID 0, an executable in /dev/shm or a file protected by the immutable attribute (chattr +i, often used to prevent deletion) are all indicators of compromise.

Explore the "Cybersecurity in the Age of AI" course

Step 4: trace the entry point through the logs

Finding the miner is not enough: you need to know how it got in, or it will come back. The most common vectors are SSH brute force against a weak password, a vulnerable web application, a service exposed without authentication (database, Redis, Docker API, admin panel) or a stolen secret.

sudo journalctl -u ssh --since "2026-09-20" | grep -E 'Accepted|Failed' | tail -50
sudo grep -E 'Accepted (password|publickey)' /var/log/auth.log*
last -a | head -20
lastb -a | head -20
sudo journalctl --since "2026-09-24 02:00" --until "2026-09-24 04:00"

On app01, the timeline is clear: thousands of failed SSH logins to the root account from several addresses, then an Accepted password for root from 198.51.100.140 at 02:47, and the dbus-sync service created four minutes later.

To list files modified during the attack window:

sudo find / -xdev -newermt "2026-09-24 02:40" ! -newermt "2026-09-24 03:30" -type f 2>/dev/null | grep -vE '^/(proc|sys)'

Keep all of this output: it forms the incident timeline and will be needed for the post-mortem, your insurer and, where applicable, breach notification obligations.

Removing the crypto miner in the right order

The first decision is simple: if the attacker got root, or if in doubt, rebuild. A root attacker may have modified any binary, including the ones you use to check. Cleaning up is only reasonable for a compromise limited to an unprivileged account, with a known vector and a complete timeline.

Situation Decision
Root access confirmed or likely Rebuild
ld.so.preload, system binaries or PAM module modified Rebuild
Unprivileged account, known vector and timeline Cleanup possible, under monitoring

On app01, the attacker got in as root: the server is rebuilt. The cleanup procedure is still worth knowing, and its order is critical: disable the restart mechanisms before killing the process.

%% titre: The order of eradication steps
%% narration: This diagram shows the order to follow: isolate the server and preserve evidence, disable persistence, and only then stop the processes and delete the files, before verifying, fixing the entry point and rotating secrets.
flowchart LR
  A["Isolate and preserve"] --> B["Disable persistence"]
  B --> C["Stop the processes"]
  C --> D["Delete the files"]
  D --> E["Verify after reboot"]
  E --> F["Fix the entry point"]
  F --> G["Rotate secrets"]
The order of eradication steps
# 1. Disable persistence
sudo systemctl disable --now dbus-sync.service
sudo systemctl mask dbus-sync.service
sudo crontab -l -u root | grep -v '/var/tmp/.font-unix' | sudo crontab -u root -

# 2. Stop remaining processes
sudo pkill -9 -f '/var/tmp/.font-unix/'

# 3. Delete the files (after copying them to the evidence folder)
sudo chattr -i /var/tmp/.font-unix/* 2>/dev/null
sudo rm -rf /var/tmp/.font-unix /etc/systemd/system/dbus-sync.service
sudo systemctl daemon-reload
sudo sysctl -w vm.nr_hugepages=0

# 4. Check that nothing comes back
sleep 300; ps -eo pid,user,%cpu,cmd --sort=-%cpu | head -5
sudo ss -tnp state established

In every case, rotate all secrets reachable from the server: passwords, SSH keys, API keys, database credentials. A miner is often just the most visible symptom of access that may have been used for something else.

Preventing the next infection

  • SSH: key-only authentication (PasswordAuthentication no), PermitRootLogin no or prohibit-password, and fail2ban to block brute force.
  • Attack surface: no admin or database service exposed to the internet; an allowlist-based firewall.
  • Egress filtering: a web server has no reason to connect to port 3333 on an unknown address. Allowing only the outbound traffic you need blocks most miners, even after a break-in.
  • Regular updates for the OS and applications, starting with internet-facing ones.
  • Monitoring: alerts on sustained high CPU outside expected windows, and on new persistent outbound connections.
  • Integrity and logs: AIDE or similar to detect modified files, auditd on /etc/systemd/system, /etc/cron* and authorized_keys, logs shipped off the server.
  • Mount /tmp and /dev/shm with noexec when your applications allow it.

Frequently asked questions

Does 100% CPU always mean a crypto miner?

No. A backup, indexing job, poorly optimized database query or traffic spike can all max out the CPU. What points to a miner is the combination: an unknown or impersonated process, a binary in a temp directory or deleted from disk, a permanent outbound connection and undocumented persistence.

Is antivirus enough to detect a crypto miner on Linux?

Not reliably. Miners are often recompiled, renamed and packed to evade signatures. The behavioral checks in this article (process, network, persistence, logs) and tooling such as rkhunter, osquery or Wazuh remain essential.

Should I reboot the server to get rid of the miner?

No, and certainly not first. A reboot restarts the persistence mechanisms, wipes memory that is useful for analysis and removes nothing. Isolate, preserve evidence, disable the restart mechanisms, then reboot to confirm nothing comes back.

Is a crypto miner dangerous if it "only mines"?

Yes. It degrades service, drives up costs and, above all, signals that someone else has gained access, often as root. That access may have been used to steal secrets, plant a backdoor or prepare something worse, such as ransomware.

Conclusion

Detecting a crypto miner on a Linux server comes down to a repeatable process: start from the symptom (a maxed-out CPU), identify the process and its real binary, confirm through the network, flush out every persistence mechanism and trace the entry point in the logs. Eradication follows a strict order, and root access means rebuilding. Prevention, finally, comes down to a few simple measures: key-based SSH, a reduced attack surface, egress filtering and monitoring. To practice these reflexes on a complete case, from detection to post-mortem, start with the free lesson on the 2026 threat landscape.

Explore the "Cybersecurity in the Age of AI" course