How to Detect a Compromised Server: 8 Warning Signs to Check
To detect a compromised server, look for behavior that breaks the pattern of a healthy system: odd processes, strange network traffic, files you did not create, and logins you did not make. No single sign proves an intrusion, but two or three together should change how you treat the server, from routine maintenance to containment. This guide gives eight checks, what each one looks like in practice, and what to do when a check fails.
Work through the checks in order, and do not clean up as you go. Deleting a suspicious file before you know how it got in destroys evidence and leaves the entry point open. Take notes, save log excerpts, and snapshot the server if your provider allows it, so you can investigate from a copy while the live server stays contained. If a scan is part of your routine, run it alongside these manual checks.
1. Suspicious Linux Processes and High CPU You Cannot Explain
Run htop or ps aux --sort=-%cpu | head -20 and look for processes you do not recognize, processes running as an unexpected user, or a process eating CPU at all hours. Crypto miners are the most common find: a process with a random name, running from /tmp or a hidden folder, using most of the CPU. A web server that spikes during traffic is normal. A miner that runs at full CPU at 4 a.m. on a quiet site is not.
Check where the process lives with ls -l /proc/<PID>/exe and what files it holds open with ls -l /proc/<PID>/fd. A deleted binary that still runs, shown as (deleted) in the exe link, is a strong sign of tampering, because legitimate services rarely run from deleted files. Do not kill it and move on: note its path, its parent process, and its start time first.
2. Unauthorized SSH Login and New User Accounts
Check recent logins with last -20 and failed attempts with sudo grep "Failed password" /var/log/auth.log | tail -20. Look for logins from countries or hours that do not match your team, and for successful logins right after a run of failures, which suggests a password finally worked. Then check for accounts you did not create:
cat /etc/passwd | grep -v nologin | grep -v false
A new user with a shell, or an old service account that suddenly has a shell, deserves a closer look. Check /etc/sudoers.d/ and the sudo group for accounts that gained admin rights, and check ~/.ssh/authorized_keys for every user for keys you did not add. An attacker key in authorized_keys survives a password change, which is why password resets alone never finish a cleanup. Our SSH hardening guide shows the settings that make this entry harder next time.
3. Server Compromise Signs in Files and Timestamps
Look for files modified recently in places that should be stable. Check web roots and system folders with:
sudo find /var/www /etc /usr/local/bin -type f -mtime -7 -ls
A PHP file in an uploads folder, a new binary in /usr/local/bin, or a cron file you did not write all point at the same story. Check cron for every user with sudo crontab -l and ls /etc/cron.d/, because a cron entry that re-downloads malware every hour is how an infection survives a cleanup. Also check for hidden files and folders, with names starting with a dot, in web roots and home folders, since those hide in plain sight in normal listings.
4. Odd Outbound Traffic and New Listening Ports
A compromised server often talks outward: to a command server, to a mining pool, or to new victims in a scan. Check listening ports with sudo ss -tlnp and compare against the services you run. An unexpected listening port, especially a high port with no service you recognize, needs an owner process check with the same tool. Check live connections with sudo ss -tnp and look for long-lived connections to addresses you cannot place.
Bandwidth graphs help here. A server that suddenly sends far more traffic than it receives, or that shows steady outbound traffic at night, is often part of a botnet or a mining operation. Your provider panel usually shows this graph even when the server itself looks calm, because the traffic never reaches a shell you would notice.
5. Changed System Binaries and Missing Logs
Compare key binaries against package records with dpkg -V on Debian-based systems, which flags files that differ from the installed package. A changed ls, ps, or ss binary is a classic rootkit move, because it lets the attacker hide processes and files from the very tools you use to look for them. If those tools cannot be trusted, investigate from a live image or a snapshot mounted elsewhere, not from the compromised system itself.
Missing or truncated logs are another sign. Check for gaps in /var/log/auth.log and /var/log/syslog around the time of a suspicious event. Attackers clear logs to hide logins, but a gap is itself evidence, because normal logs do not skip hours without a rotation entry. A log file that is empty or far smaller than its neighbors deserves the same suspicion as a log full of failures.
6. Website Defacement, Spam, and Search Warnings
For a web server, the visible signs often arrive first: changed homepage text, injected links to unrelated sites, spam pages under your domain, or a browser warning that the site is dangerous. Check for injected content with a scan of the web root, and check search results for pages under your domain that you never published. Spam pages are often hidden from normal navigation but indexed by search engines, which is why a search for site:yourdomain.com sometimes finds the compromise before you do.
Mail is a quieter version of the same sign. If your server starts sending spam, provider mail queues fill, and your IP lands on blocklists. Check the mail queue with mailq or your panel, and check whether your IP appears on a public blocklist. A spam run from your server is both a symptom and a second problem, because cleaning the site without fixing the mail path leaves the blocklist problem in place. The Fail2ban jails guide shows how mail and SSH protections fit together.
7. Services That Crash, Restart, or Refuse to Start
A service that crashes without a config change, a database that restarts nightly, or a web server that refuses to start after a reboot can all trace back to a compromise: a replaced binary, a full disk from log spam or a miner, or a config file edited by someone else. Check disk use with df -h and the largest folders with du -sh /var/*, because a full disk causes a wide range of confusing failures that look like app bugs.
Read the service logs for the crash, not just the fact of it. A crash with an out-of-memory error on a server that normally idles points at a runaway process. A crash with a permission error on a file that used to work points at a changed owner or mode. Either way, treat an unexplained crash as a prompt to run the other checks, not as a reason to restart and forget.
Detect a Compromised Server: Security Tools Disabled Without You
Check that your firewall and intrusion tools are still running: sudo ufw status, sudo systemctl status fail2ban, and the status of any monitoring agent. Attackers disable the tools that would report them, so a stopped firewall with no maintenance behind it is a sign, not a coincidence. The same applies to config changes: a firewall rule that now allows a new port, an SSH setting that re-enabled password login, or a monitoring agent that stopped reporting all need an explanation from a human, not just a restart.
When two or more signs point the same way, contain first: take the server or the affected site offline or behind a firewall, block outbound traffic except what you need for investigation, change credentials from a clean machine, and restore from a backup taken before the compromise where you cannot verify every file. Our WordPress security basics guide covers the app-layer cleanup that often follows a server-level find. A fast cleanup that leaves the entry open is not a cleanup, and a slow, documented one is the only kind that holds.