Home > Articles > Operating Systems, Server > Linux/UNIX/Open Source

The Dirty Work: Maintaining Basic Linux Systems Security

Unix systems administrator Jon Lasser discusses the top six technical steps necessary to provide basic Linux systems security, from backing up your system to avoiding cleartext protocols.

This article is derived from /etc/hosts, Jon's column in Web Hosting magazine.

Like this article? We recommend

Like this article? We recommend

So it's time to secure your system. You've marshaled your resources to allow enough time to get it done, you have equipment, and you know what you're trying to secure and why. But what are the first steps you should take to secure a system?

Briefly, the top six steps to secure a Linux (or Unix) system are:

  1. Keep current backups.
  2. Disable unnecessary services.
  3. Keep system patches current.
  4. Limit access to resources.
  5. Avoid cleartext protocols.
  6. Automate what you can.

Before we can examine these points individually, we need to take a step back and look at how systems are cracked in the first place.

How Boxes Are Broken Into

If we intend to keep crackers out of our systems, we have to know how they get into them. Most cracked boxes I've seen have two things in common: too many unused services running, and too few updates or patches installed. Both of these are errors in administration, and are avoidable with just a little bit of knowledge.

Recently, I spent a portion of my time cleaning up after a hacker attack on a Linux box. It wasn't a Linux box that I ran; to protect its identity, let's call the box, "Spike," and its system administrator, "Pete." Spike was a Red Hat Linux 6.0 box.

What generally happens is this: An admin like Pete installs the system with every option turned on. "Well, I don't know what all of this stuff is," he might say, "so I'd better install all of it now, just in case." Because Pete is new to the admin game, it doesn't occur to him that every service adds to the number of potential security holes on his system. Because Pete also doesn't read Bugtraq or keep up with his distribution's security announcement mailing list, he doesn't realize when one of those programs he's got running is now exploitable, so he doesn't patch the system.

Thousands upon thousands of "script kiddies"—wannabe crackers with no discernible talent—are constantly scanning as many computers attached to the Internet as they can. Sooner or later, one of them will happen upon Spike and realize that there's an "exploit," a pre-packaged script that will open up a latent security hole, which will run on that system. Moments later, that script kiddie has root privileges on Spike.

Now, let’s take a more in-depth look at the top six steps to secure a Linux (or Unix) system.

1. Keep Current Backups

It's a mistake to think that these things only happen to other admins, especially only to admins less knowledgeable than ourselves. No security is ever perfect, and it's always possible that a master hacker has decided to break into your system using his own skills and exploiting holes not yet publicly known.

The only reasonable preventative technique is to keep current backups, preferably two weeks to two months' worth of backups for your system. That way, once you detect an attack, you can figure out what's been changed and recover what's been deleted.

Backups are also an important issue with regard to physical security: What happens to your critical files if your machines are stolen, or if your building burns to the ground? Look at off-site backups for any files that are business-critical.

Whoever hacked Pete's machine installed a "rootkit," a set of replacement utilities that can hide changes to the system—for example, a replacement for 'ls' that hides specific files in directory listings. It's notoriously difficult to clean up after a rootkit has been installed, and it's best just to copy known-safe data files onto a freshly installed system. Without backups, it's impossible to be truly confident about the safety of a system.

2. Disable Unnecessary Services

New exploits will be found. Fewer things are more certain in the computer security world than the constant development of new exploits. The best way to limit your exposure to unknown exploits is to not run software you don't need. If you discover that you need the package, it's always relatively easy to install it later. Spike was running DNS services, even though we were already providing DNS and even though it wasn't properly configured and thus was doing no good.

Recently, a "back door" was reported for Red Hat's "piranha" utility, which provides basic clustering services. However, the back door turned out to be a default password, and piranha can't be used until that password is changed. Nevertheless, dozens or hundreds of machines were broken into through this method. Because removing this hole is necessary for the software to be useful, it's clear that large numbers of people are running software that they're not using. Don't be one of them.

The best way to disable a service is to remove it entirely from your system. Most systems use package management software to handle installing and removing software. The two most popular package managers are RPM (the Red Hat Package Manager) and dpkg (the Debian package management system). RPM is used not only by Red Hat Linux, but also by SuSE Linux and others; dpkg is used by Debian Linux, Storm Linux, and Corel Linux, among others.

If you're using a system based on the RPM package manager, you can find out what package contains a given executable by running the command rpm -qf /path/to/program/I/want/to/remove. The q option is for query, and f indicates that you want to query the database for a given file. RPM will return the name of the package that owns this file, if it was installed via RPM. The package name will look something like insecure_garbage-1.0-1, and you can then remove the package with rpm -e insecure_garbage.

If your system uses the Debian package management system, you can locate the package that owns the offending program by running dpkg --search /pth/to/program/I/want/to/remove. After this, you can remove the package with the command dpkg -r insecure_garbage.

Remember, if it's not installed, it can't be exploited!

3. Keep System Patches Current

Even though Pete had installed the name server on Spike, he might have been protected if he had also updated his system: As near as I can tell, Spike was cracked in the middle of April—but Red Hat had a fix for the problem announced in the middle of last November, making the hole at least six months old. This may sound extremely lax of Pete, but I've seen machines broken into through holes that had fixes available more than a year earlier.

Sometimes it's difficult to know that you need to update your software, but most of the time, vendors have email lists you can subscribe to that will notify you of security patches. Certainly, virtually all vendors have Web pages with the appropriate information. If your Linux distribution doesn't have such a Web page, I strongly advise switching systems as soon as this is feasible. In any case, joining the appropriate mailing list is a must to keep your system updated.

NOTE: Linux Distribution-Specific Security Mailing Lists

Red Hat Linux

Send mail to redhat-watch-list-request@redhat.com with the word "subscribe" (no quotes) as the subject

Debian

Send mail to debian-security-announce-REQUEST@lists.debian.org with the word "subscribe" (no quotes) as the subject

SuSE

Send a blank email to suse-security-announce-subscribe@suse.com

Mandrake

Send an email with the subject "SUB security" (no quotes) to symp@linux-mandrake.com

Slackware

Send an email to majordomo@slackware.com with the line “subscribe slackware-security” in the body of the message

4. Limit Access to Resources

Limit physical access to your systems to necessary personnel: Your data is not safe if a thief can walk off with your server, or if any guy in a brown UPS jumpsuit can walk out of your building with a pile of hard drives. Make sure you have policies regarding physical access, and that those policies are followed. If your server is not safely locked away, or in a monitored machine room, you run a great risk: Given physical access to the machine, any halfway-competent sysadmin or cracker can gain root access in minutes, and might install a back door on your system.

You can limit access to resources on the software side of things, too. Linux Pluggable Authentication Modules (PAM) allow you to control the maximum size of files on your system, the maximum number of processes a user can run, the maximum amount of memory a user can allocate, and so on. If you want to prevent a denial-of-service attack, configuring these resources is critical. PAM also lets you control which users can log on at what times, and what sort of authentication is required to do so: If you want to allow your users to log in only from nine to five—that is, if you have no interest in their accomplishing useful work—you could set PAM to do so. PAM handles different configurations for users and groups of users, so you can give your sysadmins more flexibility than your janitors, if you so desire.

More information on Linux PAM is available at http://www.kernel.org/pub/linux/libs/pam/.

Firewalls may be your friend as well. Although a firewall is only a tool for implementing a policy, a strong implementation of a strong policy is a good addition to your security structure. Your default policy, of course, should be to deny any sort of connection. You can then make exceptions for specific traffic: Allow any DNS connections from offsite to my DNS servers, allow anyone at all to send Web requests to my Web servers, and so on.

If you're not rich enough to throw hardware at the problem, most modern Linux distributions (that is, those based on the 2.2 series of kernels) have IP Chains, a stateless firewall solution. It's not as effective as a real firewall, but it's quick to set up and will do a pretty good job of things. More information on IP Chains is available at http://www.linuxdoc.org/HOWTO/IPCHAINS-HOWTO.html.

5. Avoid Cleartext Protocols

Any time you send passwords in the clear over your network, you're asking for trouble. Any service you provide to users outside of your network that depends on sending cleartext passwords over your network is asking for trouble. Any questions?

Unfortunately, it's not that simple: telnet, rlogin, rsh, FTP, POP3, and IMAP4 all use cleartext passwords. (IMAP4 does not always require cleartext passwords, but it does support them.) If you offer mail accounts to your users, they will demand POP3 and IMAP4. Although SSL-encrypted versions of those protocols are available, not everyone has a client capable of using the secure protocol, so you will have to provide the insecure protocol as well, subjecting those users to possible password-sniffing attacks. But minimizing your exposure is a good thing: Any time that you can choose not to send passwords unencrypted over the network, you should choose to do so. Install the SSL-enabled IMAP and POP daemons; not all your users will avail themselves of them, but it can't hurt.

Whenever possible, use SSH instead of telnet, rlogin, rsh, rcp, and FTP. SSH is a replacement for all of those protocols (with the partial exception of FTP) that automatically encrypts your connection, protecting you from password sniffing. The official version of SSH is commercial software; their Web site is http://www.ssh.fi/.

OpenSSH, a freeware clone of SSH, is now available as well. Because of SSH's odd license, I highly recommend using OpenSSH wherever possible; the OpenSSH Web site is at http://www.openssh.com/.

Anthony Santoni, administrator at Orisis.net—a Linux-based Maryland Web hosting company—says that SSH has protected his users. He says, "I have seen systems on shared networks compromised by sniffers relatively easily. The only accounts that were not acquired were those users connecting via SSH. It is so very easy for a person on a shared network to pull down a sniffer and just wait for the passwords to come in." Of course, having a switched network is no protection if your mail server, or any other generally used service, is compromised, Santoni notes, "On a switched network(i.e., one that is not contention-based), sniffing is a little harder. You have to compromise one machine first, then set the sniffer up there to catch passwords going out to other servers."

6. Automate What You Can

Wherever possible, choose not to do the dirty work yourself. Anthony Santoni says, "With any online business, the name of the game is automation. Good admins and developers do their very best not to do the same work over and over again. If you can automate tasks, you can then move on to the next issue on your plate. In reference to Web development, automation through CGI, mailing lists, and dynamic content is necessary for increased hits and customer convenience. The more you automate, the more resources you free up for other work." I couldn't have said it any better myself.

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.

Overview


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information


To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.

Surveys

Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.

Newsletters

If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information


Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.

Security


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.

Children


This site is not directed to children under the age of 13.

Marketing


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information


If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.

Choice/Opt-out


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information


Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents


California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure


Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.

Links


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact


Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice


We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020