Before you start
- Work from a computer you trust. If your own PC may be infected, use another device to change passwords.
- Do not delete suspicious files yet. You need them to find out what happened.
- Have access to the VNC console and rescue mode on a VPS. On a dedicated server, open a ticket if you need console access or a reinstall.
What are the signs that a Linux server is hacked?
- Logins you do not recognise in
lastor the SSH log. - New users, new SSH keys in
authorized_keys, or new sudo rights. - High CPU from an unknown process (often a cryptocurrency miner).
- Unknown cron jobs or systemd services.
- Outgoing spam or attack traffic, or an abuse report about your IP address.
- Changed website files, unknown PHP files in upload folders, or redirects to other sites.
Step 1: Cut off the attacker
1
Take a snapshot or backup first
A snapshot keeps the evidence before you change anything. See schedule and restore backups. Label it clearly as compromised so you never restore it by mistake.
2
Limit network access
Allow SSH only from your own IP address, using the VNC console if needed:Replace
- Ubuntu / Debian (UFW)
- AlmaLinux / Rocky (firewalld)
ufw reset removes all existing rules, including ones that allow SSH from anywhere. Run this from the VNC console:203.0.113.10 with your own public IP address. You can also restrict traffic in the firewall panel.3
Change every credential
From a clean computer, change the root password, every user password, your client area and panel passwords, and database, email and API passwords stored on the server. Create a new SSH key pair; the old private key may be stolen.
Step 2: Find out how they got in
Run these checks and write down anything you did not create.Who logged in and when?
-u sshd on AlmaLinux/Rocky. See check login history.
Which users and keys exist?
nobody (UID 65534) is a normal system account. Any other user with UID 0 besides root, or a key you did not add, is a backdoor.
What runs on a schedule or at boot?
What is running and listening?
/tmp, /dev/shm or /var/tmp, and connections to unknown addresses.
Which files changed recently?
sudo apt install debsums and sudo debsums -c list package files whose contents changed. On AlmaLinux/Rocky, sudo rpm -Va does the same.
Then run a malware and rootkit scan. Common ways in are a weak or reused password, an outdated web application or plugin (for example WordPress), an exposed database or admin panel, and a stolen SSH key.
Step 3: Rebuild and restore
1
Copy off the data you need
Copy website files, databases and configuration to a safe place. Treat them as untrusted: check them before you restore.
2
Reinstall the operating system
Use a current, supported release. On a VPS, see rebuild and reinstall your VPS. On a dedicated server, open a ticket.
3
Harden before you go live
Work through the Linux server hardening checklist: updates, a sudo user, SSH keys only, a firewall and Fail2Ban or CrowdSec.
4
Restore clean data only
Restore from a backup made before the break-in. Update every application to its latest version, and reinstall plugins and themes from their official source instead of copying them.
5
Fix the way in
Close the hole you found in Step 2. If you could not find it, assume it was a stolen password or an outdated application, and change both.
Can I clean a hacked server without reinstalling?
Only if you are certain what the attacker changed, for example one infected upload in a website with no root access gained. Once an attacker has had root, they can hide tools that scanners miss, so a reinstall is the only way to be sure.Frequently asked questions
How did my server get hacked if I use strong passwords?
Many break-ins use an outdated web application, a plugin with a known flaw, or a key or password stolen from another machine. Check web server logs as well as SSH logs.Should I report the attack?
If your server attacked others or sent spam, answer any abuse report you receive with what you found and what you fixed. If personal data was exposed, check your legal duties to report it.My server is mining cryptocurrency. Is killing the process enough?
No. Miners usually come back through a cron job, a systemd service or a backdoor. Follow all three steps.How do I prevent this next time?
Turn on automatic security updates, use SSH keys only, keep off-server backups, and review logins regularly.Related guides
VPS and dedicated server guides
Every guide in this section.
Scan for malware
ClamAV and rkhunter.
Check login history
Find unknown logins.
Security checklist
Harden the new server.
Back up a Linux server
Be ready next time.
Rescue mode
Access your disk safely.
Checked against the official manuals for OpenSSH, util-linux, procps, iproute2, debsums and rpm, and the Ubuntu Server firewall documentation on 4 November 2026; the inspection commands were tested on Ubuntu 24.04 LTS. Commands can differ on other distributions or releases.
Need Extra Help?
If you encounter any issues, our support team is ready to assist:- Live Chat: Quick assistance via our website.
- Support Ticket: Open a Ticket
- Discord: Join our Community
- Email: support@freakhosting.com
Last Updated: November 2026