For Unix-based systems, this should include the following:
* Disable telnet.
* Limit SSH access to specific IP addresses.
* Disable direct root login.
* Remove unnecessary packages / software.
* Harden the kernel against synflood and basic DOS attacks.
* Remove common user access to compilers and fetching software (wget, fetch, lynx, etc.).
* Ensure /tmp is in its own partition with noexec, nosuid.
* Ensure kernel and software is up to date.
* Remove unnecessary users and groups.
* Install chkrootkit, logwatch, tripwire.
* Install a firewall, and port scan detector.
* For Apache servers, install mod_security and configure for use with FrontPage, PHPMyAdmin, Site Studio, and other common applications.
* Secure DNS Servers
* Utilize firewall automation to mitigate brute force FTP, syn floods, mail bombs, and out-of-network trojan’d servers from impacting your servers
It is important to note that security is an ongoing venture. Even if you were to take all of the steps listed above, you would still have a regular routine of review, update, research, patch, etc.
While it can be painful, when you are hacked, you will want to wipe the system, reinstall the operating system, install applications which must be installed fresh, and restore from a backup made prior to the hack.
Otherwise, you may be guessing did you get everything including the back door the hacker may have set up when you tried to clean things by hand.
Debugging everything and recompiling lots of stuff just to make sure it's not backdoor'ed anymore will most likely consume more time and money than clean OS reinstall, restore from backup and secure the server from the scratch.