Seven steps to increase Linux security

TechRepublic

Ask a network administrator in any large organisation to compare Linux with network operating systems like Windows NT or Novell Open Enterprise Server, and chances are he'll admit that Linux is an inherently more stable and scalable solution. Chances are he'll also admit that when it comes to securing the system from outside attack, Linux is possibly the most difficult of the three to work with.

This perception is not an uncommon one -- many network administrators new to Linux find it hard to transition from a point-and-click security configuration interface to one based on editing complicated and hard-to-locate text files. Most administrators are well aware of the need to manually put in roadblocks and obstacles to trip up would-be hackers and ensure that your company's data stays secure; it's just that in the unfamiliar Linux world, they're not completely sure of their bearings or where to start.

That's where this document comes in. It outlines some easy things administrators can do to make their Linux server more secure and significantly reduce the risk they face. This tutorial lists seven such items.

1. Protect the root account
The root, or superuser, account on a Linux system is like a backstage pass at a Stones concert -- it allows you access to anything and everything. For this reason, it's well worth taking extra steps to protect it. Start by setting a hard-to-guess password for this account with the passwd command, change it on a regular basis, and restrict knowledge of the password to a few (ideally, only two) key people in the organisation.

Next, restrict the terminals that can be used for root access, by editing the file /etc/securetty. To avoid users leaving a root terminal "open", set a timeout for inactive root logins by setting the TMOUT local variable, and ensure that the root command history file (which might contain sensitive information) is disabled by setting the HISTFILESIZE local variable to 0. Finally, enforce a policy of using this account only to perform specific administrative tasks, and discourage users from logging in as root by default.

Tip: Once you've closed these holes, the next step is to require that every normal user account must have a password and ensure that passwords do not use easily-recognisable heuristics such as birthdays, user names or dictionary words.

2. Install a firewall
A firewall lets you filter data packets travelling in and out of your server and ensures that only those packets matching pre-defined rules are permitted to enter or exit. A number of excellent firewalls are available for Linux, and firewall code can even be compiled directly into the kernel. Begin by defining input, output and forwarding rules for packets leaving and entering your network, using the ipchains or iptables commands. Rules may be specified on the basis of IP addresses, network interfaces, ports, protocols or combinations of these attributes; these rules also specify what action (accept, reject, forward) to take when a match occurs. Once the rules are installed, test the firewall extensively to ensure that no holes exist in it. A good firewall is your first line of defence against common attacks like the distributed denial of service (DDoS) attack.

3. Use OpenSSH for network transactions
An important issue in client-server architecture involves the security of data being transmitted over the network. If network transactions take place in plaintext, it is possible for a hacker to "sniff" the data packets being transmitted and thus gain access to sensitive information. You can close this hole by using a secure shell utility like OpenSSH to create a secure encrypted "tunnel" for your data to pass through. Encrypting your connections in this manner makes it extremely hard for unauthorised users to read the data going back and forth between network hosts.

4. Disable unwanted services
Most Linux systems are installed with a wide variety of different services enabled, such as FTP, telnet, UUCP, ntalk and so on. In most cases, these services are rarely used and leaving them active is like leaving your windows open for a burglar to slip in. You can disable these services by commenting them out in the /etc/inetd.conf or /etc/xinetd.conf files and then restarting the inetd or xinetd daemon. Additionally, some services (for example, database servers) may start up by default during the boot process; you can disable these by editing the /etc/rc.d/* directory hierarchy. Many experienced administrators disable all system services, only leaving SSH communication ports open.

5. Use a spam and anti-virus filter
Junk e-mail and viruses annoy your users and can sometimes cause critical network failures. Linux is surprisingly resistant to viruses, but client machines running Windows may be more susceptible. Therefore, it's a good idea to install a spam and virus filter on your mail server itself, to "defang" suspicious messages and reduce the risk of a chain of collapses.

Begin by installing SpamAssassin, a leading open-source tool that uses a combination of different techniques to identify and flag spam; the program also supports user-based whitelisting and graylisting for greater accuracy. Next, install procmail for user-level filtering based on regular expressions; this tool allows automatic filtering of received email into mailboxes, at both a user and system level. Finally, install Clam Anti-Virus, a free anti-virus toolkit that integrates with sendmail and SpamAssassin and supports on-access scanning of email attachments.

6. Install an intrusion detection system
Intrusion detection systems (IDS) are early warning systems that let you know if changes occur on your network. They're a great way to identify (and prove) attempts to break into your system, although at the cost of increased resource consumption and potential red herrings. There are two fairly well-known IDS' you can try: tripwire, which tracks file signatures to detect modifications; and snort, which use rules-based directives to perform real-time packet analysis and search and identify attempts to probe or attack your system. Both packets can generate e-mail alerts (among other actions) and are useful when you suspect your network is being compromised but need definitive proof.

7. Perform regular security audits
When it comes to securing your network, this final step is possibly the most important. Here, you put on a black hat and do your best to circumvent the defences you erected in the previous steps. Doing this provides you with an immediate and objective assessment of how hard your system really is, and identifies potential vulnerabilities that you should fix.

A number of tools are available to help you in this audit: you can attempt to hack your password files using password crackers like Crack and John the Ripper; you can use nmap or netstat to look for open ports; you can sniff the network using tcpdump; and you can try exploiting publicised holes in your installed programs (Web server, firewall, Samba) to see if they offer a way in. If you do manage to find a way past your obstacles, rest assured that others will too; take immediate measures to close the openings.

Protecting your Linux system is an ongoing task, and so you shouldn't rest easy once you've done the steps above. Visit the Linux security forums for more security tips, and be proactive in monitoring and updating the security of your system. Good luck!

TechRepublic is the online community and information resource for all IT professionals, from support staff to executives. We offer in-depth technical articles written for IT professionals by IT professionals. In addition to articles on everything from Windows to e-mail to firewalls, we offer IT industry analysis, downloads, management tips, discussion forums, and e-newsletters.

Talkback

Add your opinion

In order to post a comment, you need to be registered. (Sign In or register below)

Post your comment

Terms of Service - As a ZDNet registrant, and by using this service, you indicate that you agree to our Terms and Conditions and have read and understand our Privacy Policy.

Tech Blueprint

ZDNet Australia Live

RT @KateKendall: 'Is it time for a C-level social media executive?' --> http://t.co/pj5RHesJ

Free and bundled are not the same thing. If they sell more than one thing, and one is free on the basis you buy the other then it is a b...

21 minutes ago by twharte on Full Spectrum: Optus 'free' broadband

RT @KateKendall: 'Is it time for a C-level social media executive?' --> http://t.co/pj5RHesJ

Is it time for a C-level #socialmedia executive? Or is #socialbusiness more likely? #in via @KateKendall http://t.co/u42u2c3p

From personal experience, patents saved us. We developed a very unique software which thanks to a couple of smart friends encouraged us t...

47 minutes ago by fred9999 on The world needs patents: Uniloc founder

#Windows malware: are you safer today than you were 10 years ago? - http://t.co/iGTJDtpB - #security

Searching for data scientists as a service http://t.co/2O5Fpx7c

Group Policy Update in #Windows8 http://t.co/ZYy3wTLd
Nice one Alan, thanks for the info @alanburchill

Searching for data scientists as a service http://t.co/BzEcbXQP

RT @ZDNet: Searching for data scientists as a service http://t.co/BzEcbXQP

RT @ZDNet: Leaked screenshots: Facebook Pages Manager for iPhone http://t.co/QxhGtQzq

Android malware families nearly quadr…: http://t.co/jUb5anha most discussed on @PhysicalDrive0/infosec-2 (http://t.co/pFj3vecC)

Android malware families nearly quadruple from 2011 to 2012 http://t.co/b7fk2d2k

Android malware families nearly quadruple from 2011 to 2012 http://t.co/WItL8HeH

Android malware families nearly quadruple from 2011 to 2012 http://t.co/M3n5tQY5

#BYOD: The Promise and Specter of IT's #BraveNewWorld (#video) http://t.co/9vxQd7EL

Google Knowledge Graph: This is why they changed their privacy policy http://t.co/hAU2ndaf

BYOD: The Promise and Specter of IT's Brave New World (video) http://t.co/5UGSvT3K #BYOD

BYOD: The Promise and Specter of IT's Brave New World (video) http://t.co/KrlwG2CR #BYOD

Anonymous denies it is behind The Pirate Bay DDoS attack: The hacktivist group Anonymous has denied ... http://t.co/Cw5mwnQv #Technology

Google Knowledge Graph: This is why they changed their privacy policy: Who needs a social graph when... http://t.co/7lJk2T0a #Technology

Leaked screenshots: Facebook Pages Manager for iPhone: Screenshots of a new app from Facebook called... http://t.co/jRPQIrHL #Technology

BYOD: The Promise and Specter of IT's Brave New World (video): Join experts and CBS Interactive edit... http://t.co/3QaKRuFJ #Technology

Why Facebook co-founder Eduardo Saverin is a schmuck | ZDNet - http://t.co/vqEwqWsz

Leaked screenshots: Facebook Pages Manager for iPhone http://t.co/aLnPl1Sw #facebook

Good commentary on trust -> Dropbox and Angry Birds are blacklisted Mobile Apps http://t.co/xP2zRLAm

Searching for data scientists as a service http://t.co/Sj5a33wi

RT @ZDNet: Searching for data scientists as a service http://t.co/BzEcbXQP

http://t.co/Ac2qJYJo

Android malware families nearly quadruple from 2011 to 2012 http://t.co/cvaZ00Oi

Anonymous 'crippled': where to for hacktivism? http://t.co/6ulsFJ19 via @zdnetaustralia

Kevin your childish intentional misspelling of a persons name, or worse, through ignorance does your argument no good.

1 hour ago by sydneyla on Malaysia held up as NBN king

RT @Hamish_E: Great @Xero review on zdnet. http://t.co/dLRrWSW6

What apps hide in corporate networks? http://t.co/h8RJ0mWE

What’s better than MDM? MokiMobility MDM. | ZDNet http://t.co/VXmAL3Ps An iPad kiosk solution that users can break out of.

Leaked screenshots: Facebook Pages Manager for iPhone http://t.co/dflFoGix

Your passwords don't suck, it's your policies - ZDNet (blog) http://t.co/OVhQqlaB

Leaked screenshots: Facebook Pages Manager for iPhone http://t.co/SezCUKWF #AppleiPhone #Facebook #App #SocialMedia #news #hot #business

"NBN powered public WiFi " - what a joke!!! You are kidding surely??? There is no plan whatsoever for any such thing. Labor's concept ...

4 hours ago by FredShekel on NBN contracts may be left alone: Turnbull

Typical ignorami. The Labor NBN plan is this: 1. Build a monopoly network through NBN.co. 2. Sell the network to the highest bidder...

4 hours ago by FredShekel on Malaysia held up as NBN king

http://en.wikipedia.org/wiki/Patent_troll "Patent troll is a term used for a person or company who buys and enforces patents against one ...

4 hours ago by victim of patent troll on The world needs patents: Uniloc founder

You are a true member Humbert. You can use whatever word you like, however not when you are trying to imply that I said something I did ...

6 hours ago by FredShekel on NBN FUD: will Abbott ever learn?

Oh, just let me jump in here and pretend to be intelligent. Realismbias, you are a full on DORK!

6 hours ago by FredShekel on NBN FUD: will Abbott ever learn?

Beta Beta Beta Beta...... you are just stupid. Please show the World where I said anything about living in an Alcatel Lucent lab - you c...

6 hours ago by FredShekel on NBN FUD: will Abbott ever learn?

Humbert Humbert Humbert Humbert..... FTTN is fibre to the node. I am glad that at last we agree in that. Now, if you think you need fib...

6 hours ago by FredShekel on NBN FUD: will Abbott ever learn?

viditor you are giving him way too much credit. Let me explain to you something about posters like fred, they resort to lines like that ...

8 hours ago by Hubert Cumberdale on NBN FUD: will Abbott ever learn?

Would somebody kindly ban this troll FredShekel? He even boasts of trolling... "I'm not crying about the NBN Humbert, I just like to pla...

8 hours ago by viditor on NBN FUD: will Abbott ever learn?

For your (badly needed) education, Freddy... 1. Uploads are far more expensive to provide than downloads because of the price of backhaul...

9 hours ago by viditor on NBN FUD: will Abbott ever learn?

Beta, I read the site most days and only comment when i need some entertainment. Today about 8 hours ago comments were a bit slow so I th...

10 hours ago by Doubt on NBN FUD: will Abbott ever learn?

lol, that comment made my day too, they make it far to easy for us though. Seriously though there are many hardcore geeky types that find...

10 hours ago by Hubert Cumberdale on NBN FUD: will Abbott ever learn?

100% agree = Windows RT = Ios, Windows 8 = Mac OS.. why is this obvious to me and you... When IOS opens it's 'mobile' OSs, then lets tal...

10 hours ago by TonyD3 on Windows RT closed to browsers: Google, Mozilla

The problem with the patent system is the fraud written into it, which means that more that 95% of inventors rights are lost due to burea...

10 hours ago by Stuart Saunders on The world needs patents: Uniloc founder

Indeed RealismBias... Feel free to laugh "along with me" and my facetious niggles at people's stupidity... just as I'm sure everyone is ...

11 hours ago by Beta on NBN FUD: will Abbott ever learn?

I actually cracked up laughing here: "He believes we should all live in the Alcatel-Lucent lab, so that we can receive commercially unav...

11 hours ago by RealismBias on NBN FUD: will Abbott ever learn?

Basic price is standard worldwide - then converted into local currency. If someone is 'gouging' then they are buying in bulk (currently n...

11 hours ago by Frotech on Only 57 Raspberry Pis in Aus: supplier

This story has been voted 15 times in the last 24 hours!

13 hours ago, AusCERT 2012 kicks off: photos

This story has been voted 5 times in the last 24 hours!

13 hours ago, Up in cyber arms: AusCERT 2012

This story has been voted 5 times in the last 24 hours!

1 day ago, NBN FUD: will Abbott ever learn?

This story has been voted 10 times in the last 24 hours!

2 days ago, Apple drops 4G iPad label in Australia

This story has been voted 5 times in the last 24 hours!

2 days ago, Apple drops 4G iPad label in Australia

Facebook Activity

Keep up with ZDNet Australia

ZDNet Events Calendar

ZDNet Events Calendar