Help for owners
Someone broke into my server
Short answer
If you think your server was broken into, treat it as untrusted. Do not delete anything, and keep a copy of the logs. Change passwords from a clean computer, tell your hosting provider, and have an engineer rebuild from a known-good state rather than cleaning in place.
Does this sound like your situation?
- The server is slow and the CPU is always at the limit.
- My host warned me about spam or attacks coming from my server.
- There are logins or files I do not recognise.
- My site shows pages or links I never made.
- Someone told me my SSH password was guessed.
Why does this happen?
Weak or reused login access
A server on the internet is probed constantly. Passwords that are guessable, or keys left in the wrong place, are the usual way in.
Technical detail: Your auth.log is full of Failed password and Invalid user attempts
Old software with known holes
Systems and apps that are no longer updated keep their known weaknesses. Attackers scan for exactly those.
A secret ended up in the wrong place
A password or key pushed to a code repository by mistake can be found and used.
Technical detail: An API key or .env file was committed to a Git repository
The hosting provider may act on it
DigitalOcean's acceptable use policy says it may suspend or terminate service even if a violation is committed unintentionally or without your authorization. A hacked server that attacks others can therefore be switched off.
Confirmed by digitalocean.com
What can I do about it today?
- Do not delete files or reinstall yetLogs and odd files are evidence of how the attacker got in. Removing them makes a proper fix harder.
- Change passwords from a clean computerUse a device you trust, not the server. Change the hosting account, the domain account, email and database passwords. Turn on two-step login where it exists.
- Tell your hosting providerWrite to their support, say you believe the server is compromised and ask what they have seen. Reply to any abuse notice.
- Ask for a copy of your dataHave the database and uploaded files copied out, to be scanned before they are reused.
- Tell people only what you knowIf customer data lived there, speak to a lawyer or adviser about notice duties before you announce anything.
When should I bring someone in?
- The server is sending spam or attacks, or the host has warned you.
- Customer data, payments or logins were stored on it.
- Nobody can say how long the server has been affected.
How do I handle it?
- Keep evidence, isolate the serverI keep a copy of the logs and the disk, and cut off the access that is being abused.
- Find how they got inBefore rebuilding I look for the entry point, so the same door is not reopened.
- Rebuild from a clean stateI prefer a new server built from known-good code, with data restored after it has been checked, over cleaning the old one.
- Rotate every secret and hardenKeys, passwords and tokens are replaced, and logins, updates and firewall rules are tightened.
- Write it upYou get a plain-language note of what happened and what changed.
The price depends on what I find, so I quote in writing after a short discovery call. Tell me what is happening and I reply within 24 hours.
What do owners ask about this?
Can I just delete the strange files?
No. You cannot be sure you found everything, and the files show how the attacker got in. Rebuild instead.
Will my host switch me off?
It can. DigitalOcean's policy gives it discretion to suspend or terminate service, including for unintentional violations. Reply to its notices quickly.
Is this the same as a hacked website?
A hacked website is about the pages and the app. This page is about the machine under it.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Found a mistake? Tell me.
For your developer: the technical fixes
Failed password for invalid user admin from 198.51.100.23 port 40122 ssh2Your auth.log is full of Failed password and Invalid user attemptsremote: error: GH013: Repository rule violations found for refs/heads/main. (a push blocked because it contains a secret)An API key or .env file was committed to a Git repository