1: Your purpose
Linux, like Microsoft Windows, is simply a computer operating system. When I talk to friends or co-workers who are embarking on the Linux experience for their initial time, this is the first point I stress. Linux in itself is not a magic wand that can be waved and make all sorts of computing problems disappear. While Windows has its own set of problems, so too does Linux. There is no such thing as a perfect or completely secure computer operating system. Will the machine be a desktop computer or a server; purpose is a key to understanding how to initially install and configure your Linux PC.
2: Installation
Unlike Windows, Linux does not present itself as a "server" version or as a "desktop" version. During a typical installation of Linux the choice is yours as to exactly what software you wish to install and therefore exactly what type of a system you are constructing. Because of this, you need to be aware of the packages that the installation program is installing for you. For example, some distributions will configure and start a Samba server or a mail server as part of the base install. Depending upon the purpose of your Linux PC and the security level you are prepared to accept, these services may not be needed or desired at all. Taking the time to familiarize yourself with your distributions' installer can prevent many headaches and/or reinstalls down the road.
WEEKLY LINUX HOW-TOS
New Linux tutorials updated every Monday with Open Sourcery
3: Install and configure a software firewall
A local software firewall can provide a "just in case" layer of security to any type of network. These types of firewalls allow you to filter the network traffic that reaches your PC and are quite similar to the Windows Firewall. The Mandriva (http://wwwnew.mandriva.com/) package called Shorewall (http://www.shorewall.net/) along with a component of the Linux kernel called Netfilterprovides a software firewall. By installing and configuring Shorewall during the installation process, you can restrict or block certain types of network traffic, be it coming to or going out from your PC.
To access and configure your firewall for Mandriva simply run the mcc (or Mandriva Control Center) command from a command prompt or, depending upon your graphical environment, you may be able to access the Mandriva Control Center from your base system menu. In the security options, select the firewall icon and you will be presented with a list of common applications that may need access through your firewall. For example, checking the box for "SSH server" will open port 22 needed by the Secure Shell server for secure remote access. There is also an advanced section which will allow you to enter some less commonly used ports. For example, entering "8000/tcp" will open port 8000 on your PC to TCP-based network traffic.
Blocking or allowing network traffic is one layer of security, but how do you secure a service that you do allow the Internet or your intranet to connect to? Host based security is yet another layer.
4: Configuring the /etc/hosts.deny and /etc/hosts.allow files
In the preceding section we looked at the example of opening the Secure Shell service to network traffic by opening port 22 on our firewall. To further secure this server from unwanted traffic or potentially hackers, we may wish to limit the hosts or computers that can connect to this server application. The /etc/hosts.deny and /etc/hosts.allow files allow us to do just that.
When a computer attempts to access a service such as a secure shell server on your new Linux PC the /etc/hosts.deny and /etc/hosts.allow files will be processed and access will be granted or refused based on some easily configurable rules. Quite often for desktop Linux PC's it is very useful to place the following line in the /etc/hosts.deny file:
ALL: ALLThis will deny access to all services from all hosts. It seems pretty restrictive at first glance, but we then add hosts to the /etc/hosts.allow file that will allow us to access services. The following are examples that allow some hosts remote secure shell access:
sshd: 192.168.0.1 #allow 192.168.0.1 to access sshsshd: somebox.somedomain.com #allow somebox.somedomain.com to access ssh
These two files provide powerful host based filtering methods for your Linux PC.
5: Shutoff or remove non-essential services
Just like Windows there can be services running in the background that you either don't want or don't have a purpose for. By using the Linux command chkconfig you can see what services are running and turn them on and off as needed. Services that are not running don't provide security holes for potential hackers and don't take up those precious CPU cycles.
6: Secure your required services
If your new Linux PC has some services that will receive connections from the Internet make sure you understand their configurations and tune them as necessary. For example, if your Linux PC will receive secure shell connections make sure you check the sshconfig file (for Mandriva it is /etc/ssh/sshd_config) and disable options like root login. Every Linux PC has a root user so you should disable root login via ssh in order to dissuade brute force password crack attempts against your super-user account.
7: Tune kernel networking security options
The Linux kernel itself can provide some additional networking security. Familiarize yourself with the options in the /etc/sysctl.conf file and tune them as needed. Options in this file control, for example, what type of network information is logged in your system logs.
8: Connect the PC to a router
A hardware router is a pretty common piece of household computer hardware these days. This is the front line security to any home or business network and provides multiple PC's to share one visible or external Internet address. This is generally bad news for any hacker or otherwise malicious program that may take a look at your new Linux PC as it blocks any and all network traffic that you don't specifically allow. Home networking routers are just smaller versions of what the big companies use to separate their corporate infrastructure from the Internet.
9: Update
Always keep the software on your computer up to date with the latest security patches should you be running Linux, Windows, BSD or WhoKnowsWhat. Your distribution will release regular security patches that should be applied and are available off the Internet. As with Windows, this should always be your first Internet destination.
10: Other software
Your second Internet stop may be to install some other hardening or system monitoring software.
Bastille-Linux (http://www.bastille-linux.org/) is a program that can be used to "harden" or secure certain aspects of your new Linux PC. It interactively develops a security policy that is applied to the system and can produce reports on potential security shortcomings. On top of that it is a great tool to use for learning the in and out of securing your Linux PC.
Tripwire (http://sourceforge.net/projects/tripwire) is a software package that monitors your system binaries for unauthorized modifications. Often a hacker may modify system binaries that may be useful in detecting a system intrusion. The modified programs would then report false information to you allowing the hacker to maintain his control over your system.




1
Eliena Andrews - 30/03/07
Really nice tutorial about LINUX, thanks for sharing.. Perhaps you should write more about Tuning Network (sysctl.conf). Nice article..
» Report offensive content
2
saradhi - 30/03/07
i want to learn some thing more about linux installation and maintainence can u help me how
» Report offensive content
3
Jorge - 30/03/07
#3 You could also mention the firewall called Firestarter http://www.fs-security.com/ . Similar to Zonealarm for Windows and very easy to setup.
» Report offensive content
4
burnin - 30/03/07
a couple of additions for your other software list...
denyhosts - a script to help thwart ssh server attacks. if someone tries to brute force their way through ssh they will be added to the hosts.deny file and the attack will end.
selinux - a fine grained Mandatory Access Control add on for the kernel which can be effective at preventing or minmizing successful intrusions and zero day hacks.
» Report offensive content
5
Dan - 30/03/07
This was from 12/8/05, why is it appearing all over the place as if it were a new article?
» Report offensive content
6
arup - 30/03/07
Unlike Windows, Linux does not present itself as a "server" version or as a "desktop" version.
Distributuions like Ubuntu and many more, they do provide server/desktop installation.
» Report offensive content
7
Domester.NET - 30/03/07
It is the great article for Linux users.
» Report offensive content
8
Ugh - 30/03/07
Read a few books on security then please re-write this article. Thanks.
» Report offensive content
9
Ugh - 30/03/07
Read a few books on system and network security and then re-write this article. Thanks.
» Report offensive content
10
RobDaRobot - 30/03/07
This is a fantastic article. Although setting up Linux can sometimes be headache inducing. It's well worth it instead of a virus infested (not pointing fingers here) computer.
» Report offensive content
11
linuxiac - 30/03/07
If you can't afford a router, you can build one, cheap! Almost any Pentium Class box with a 133 to 800Mhz cpu, a 1 Gb hard drive, two NICs, and 16 Mb RAM or more, can run ipcop, headless.
Site is http://ipcop.org
Linux is free, at:
http://pclinuxos.com
http://livecdlist.com
http://distrowatch.com
GNU/Linux is "Green", letting you run on any Pentium Class system, with 350Mhz cpu and 256Mb RAM as the usual minimum requirement.
Most Distros include hundreds or even thousands of programs, consisting of games, Office Suites, applications, and Browsers.
» Report offensive content
12
systemnotes - 30/03/07
Good advice for a home system. You should mention security scanning, if the linux box is for a production environment. insecure.org is a good place to start. Bastille-Linux is great, and so easy to run.
» Report offensive content
13
p - 30/03/07
You forgot the most important thing: choose a secure password for your account if you use an ssh server. 99% of attacks exploit weak passwords on ssh.
» Report offensive content
14
Robin T Cox - 30/03/07
If you are using a router, be sure to change its default password. Typically, routers are sold with the default username 'admin' and password 'password'. Hackers know this, and can access or bypass your router unless you change its default password with one of your own - preferably a password containing a mix of numbers and letters.
» Report offensive content
15
Robrt - 31/03/07
The worst kind of advice for security is outdated and obsolete advice. This article is detrimental to the reader in its omission of current-day basics:
Relevance to current threats
PGP/GPG email
iptables
CERN advisories
SSL v2/v3
SSH protocol 1/2
password complexity and aging
» Report offensive content
16
mugatu - 31/03/07
what good are hosts.deny and hosts.allow when many distros dont even install tcpd by default and even more don't start it and even when they do, most services don't go through the tcp wrappers. there is really a lack of content here. go into detail rather than put together some crap article just to get some exposure on digg.
» Report offensive content
17
Laughing Man - 31/03/07
And this is why Microsoft will stay in business for a long, long, long, long time. This is Linux being SO not out-of-the-box. Compared to this blather, Windows and Apple are indeed out-of-the-box. Until the Linux geeks make the whole process a lot more accessible, you can keep desperately pointing to Digg for publicity and validation.
Good luck with that.
» Report offensive content
18
Nikhil - 31/03/07
Seriously this article seems to be written for server systems. If linux needs all this (and it doesn't actually) to be safe on the internet then I wonder what would windows need. The author should have specifically said that this is for server systems. Home Linux computers DO NOT need all this tinkering. Linux is more than secure out of the box.
» Report offensive content
19
Paul - 01/04/07
perhaps the most important thing you can do is slap on the Ubuntu sticker on the front of the case, or the top and show to the world you're running ubuntu
» Report offensive content
20
Johan - 02/04/07
When you use a desktop for Linux, this all is too much.
Don't use any services, not needed for a desktop, only X can broadcast, configure Xaccess and no one can make a connection form outside. Downloaded files won't get executable with a good umask (standard is 022).
» Report offensive content
21
Sid Boyce - 02/04/07
Article could be summarised by "Get a Good Distro" or put your box behind Astaro, Smoothwall, IPCop or Shorewall on an old discarded PC. When deploying Linux for novices, I use a distro with a good firewall enabled. I am able to see the breakin attempts and they don't get through. The last box I converted to Linux a few weeks ago was one where Windows was previously installed, some piece of software that Windows had a one night stand with, totally wiped a couple of partitions and they didn't have a restore CD.
» Report offensive content
22
DavidZ - 05/04/07
Good general article in under 1200 words. Hopefully it inspires the Linus techies who know better to let their fingers do the talking and post a detailed article on all the latest and greatest advances in security and Linux distros.
» Report offensive content