Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This question already has an answer here:

I have inherited a Linux Apache CentOS plesk server which has been hacked, which has websites which are in production.

I have been advised by my friend to rebuild it from scratch, since the attack apparently is quite widespread and it is hard to detect what is breached apparently.

I have never rebuilt a server, and I did not set the server in the first place, so what I am asking is, if there is a recipe or an easy to follow checklist on how to achieve a rebuild and restore everything as it should be?

share|improve this question

marked as duplicate by HopelessN00b Jan 14 '15 at 4:46

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

At this stage the normal response is "nuke it, reformat, and restore from backups".

There's tons of related questions here or on google, try searching around a bit.

edit: oh, and keep it off the network until its fixed. :)

share|improve this answer
I'd change that to "restore from known-unhacked backups", restoring a system that has been hacked, from a backup done after the hack, is about as useful as not nuking and restoring in the first place. – Vatine Oct 12 '10 at 15:01
was assuming the backups wern't an image / system files. – Sirex Oct 12 '10 at 15:51

That advice is sound. Once someone gets in they frequently create multiple self-recreating backdoors and other goodies. There's no way to verify you ever got rid of them all other than starting over from scratch. I've experience it before and it's not fun.

chkconfig --list will show you what services are running. You'll want to look at 3 and maybe 5 to see if there's anything else important running on the server. There will be a lot of services running by default that you won't really need to worry about. For the important ones, keep a copy of the configuration files for reference, but don't copy them to the new server. Maybe printing them out is the way to go. You'll need to verify and understand the settings to make sure they haven't been changed to anything harmful, but at least you'll have a starting point for what needs to be done.

For the data files (web pages), hopefully you can take them from a backup or source repository on a different server rather than having to copy them over from the hacked server. If you have to copy them you can try scanning them with antivirus software, then look for anything unusual and hope for the best.

share|improve this answer

To help you set up a server next time, you should also have a look at automatic installation software.

The important thing is that it should be a complete installation and set up without any touch of a human hand until maybe restoring data from a backup and before allowing the server back on the net.

It will help you, and future admins, when restoring servers after different disasters, like hardware failures and hack incidents like this. I will also work as a good and up to date documentation of your servers software and configuration.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.