|
That's really a much broader question than I can answer here, however, my recent experiences both being hacked, and building out a new server to replace the hacked one, are worth recording. Not only might you find it a helpful laundry list of idea for securing your server, but you might also have some ideas and experiences to share. So these are the steps I've taken to "harden" or more tightly secure a newly built out Linux server. These steps are intended to reduce the probability the server being hacked into again. The New Server ItselfIn this particular case our brand new server is built out with Redhat Enterprise Linux, with the cPanel management interface. A 2.0Ghz Xeon, with 512Meg RAM, and a 54gig hard drive. The goal at this step is actually fairly simple: start out with a popular, current, and supported, version of the OS. WHMStep one was to login to Web Host Manager (the server management front-end for cPanel), and run their configuration wizard. The only things that required non-default action were:
After the wizard was complete, these additional settings were performed manually:
Also ran Update Server Software and Update System Software within WHM to update as many components as reasonable. Linux KernelThe original configuration as delivered by the server farm:
Since that's not the latest kernel at the time of delivery, and cPanel will not update the kernel automatically, I was advised to update. I upgraded the kernel to 2.4.21-32.0.1.ELsmp, which went smoothly. Remote AccessOne of the areas for almost immediate security tweaking is remote access. If you've ever examined a server's logs, you know that they're regularly probed with various types of attacks. There are several modifications to render those attacks pointless, as well as secure remote access in general. SSHSSH, or secure shell, is the remote command-line access mechanism of choice. It's single biggest claim to fame is simply that everything is encrypted, though it includes many more features as well. I first created a couple of non-root login accounts, and installed RSA public keys for eventual RSA/public key-only logins. (Also created end-user instructions for creating, and using, SSH key pairs.) I then made the following changes to /etc/ssh/sshd_config:
TelnetI disabled telnet, as it allows passwords to be transmitted in the clear, and is a known security risk. FTPNormally at this point I would also disable the FTP service for the same reasons as Telnet - it's a known security risk. For reasons I didn't bother to investigate further, cPanel either complained repeatedly via email if the service was stopped, or it would restart it, depending on the technique I was attempting to use. I gave up on this and left the FTP service running, but blocked at the firewall, discussed below. TMPThe /tmp directory is an interesting and apparently common place for hackers to exploit to breech a system. One approach to securing it without breaking its functionality is to create it as a new partition that disallows program execution. Where in the past a hacker could use an exploit to place a file in /tmp and then execute it, the ability to execute is now removed by creating a secure /tmp partition. FirewallInstalled APF which is, essentially, an intelligent front end to the built in Linux firewall, iptables. I found a good how-to, though I did not yet configure the antidos (denial of service) component. The one change that I did make to the default configuration is that I disabled or blocked all ports that we know are not explicitly used for something specific. For example, this is where I blocked all FTP access. I also whitelisted my own static IP address, and that of the client. LoggingLogwatch is a server log summary tool that emails a report to the server admins nightly. An older version was installed. I updated to latest, and increased the reporting level to "medium". Rootkit ChecksInstalled nightly backup script, which includes nightly reporting of both rkhunter and chkrootkit runs. ApacheInstalled mod_security, which guards against exploits via the Apache web server, using a basic ruleset. This how to was helpful in setting that up. GeneralA few additional tweaks and settings ...
Ongoing MaintenanceEven with all the tools and updates in place, there's still on-going work and vigilance required.
Still More OptionsI haven't implemented these, but they've been recommended, and they're on the list to evaluate at some point.
Related:
• Recent Comments
how to setup web&mail server Ofredhat linux12(fedore core3) can i publish this in my magazine i will mention you as the author and also put a link to your webste Posted by: Aniket Dasgupta at September 27, 2006 11:05 PMRepublishing terms & conditions are here: http://ask-leo.com/terms.html - if they don't work for you, email me directly. Posted by: Leo Notenboom at October 4, 2006 03:28 PM
Following article suggest some of CPanel's setting. It could be useful for others. Vijay. Posted by: Vijay at October 12, 2006 07:15 AMPost a comment on "How should I set up my Linux Web Server?":
|
Archives Advertisers |