473,493 Members | 2,254 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Linux Web Server Security Thread

dlite922
1,584 Recognized Expert Top Contributor
There's copious amount of information on the internet about how to secure your web server against script kiddies and junior hackers. As a beginner, it all looks scattered and sometimes conflict (or two ways of doing the same thing apparently) and can't really decide the copy paste scripts are really good for me.

I'm building my CentOS server and would like everyone to contribute on the common things you would to secure the webserver. I'm not really looking for how to's here but list of tasks. I'd like to stick to security for the most part.

Topic: Linux Webserver (LAMP) Security

I'll start with the basics:

#] Strong passwords!

#] Get all security updates

#] Do not allow root access in SSH and FTP, and perhaps change the default port 22 to something else, like 8877 and add ListenAddress

#] Lock down all ports not used in iptables (Any other tips on IP tables? good links?)

#] Create another user and do not use root, the other user should be in the sudoer file, perhaps can execute only certain commands

#] (Sort of Security): Do not boot to X-Windows, use runlevel 3, see inittab file. you can always start x-windows by typing "startx", saves memory.



I'm sure there's many more, but that's what I can think of right now, please suggest anything and everything you can so we can have a good collection here.

Thanks!



Dan




4. Get all security updates
Dec 10 '08 #1
2 2276
Nepomuk
3,112 Recognized Expert Specialist
Hi Dan!

Security updates... CentOS is a RedHat distribution if I remember correctly, so it will probably use YUM as an updater. You can edit /etc/yum/yum-updatesd.conf (change the entry do_update no to do_update yes) to make it install updates automatically. That would be for all of your software, not just security stuff.

About ssh: You should have a look at /etc/ssh/sshd_config and the sshd manpage. One thing that may be interesting to you is the DenyUsers and AllowUsers option - a black- or whiltelist. Find out more here.

I'm no expert when it comes to iptables, but this article looks like it should help you with quite a few issues.

sudo: I'm going to write an entry to the Tips and Tricks thread about editing the sudoers file soon, so I won't write much about that right now. Of course, you can always check the sudoers manpage.

Booting? If you're using Grub as a boot manager, add something like
Expand|Select|Wrap|Line Numbers
  1. kernel /boot/vmlinuz-2.6.xx ro root=/dev/hda6 3
(changing it to your actual vmlinuz-2.6.xx of course) to /boot/grub/menu.lst and set it as standard. That way, you can still boot with a GUI if you want to.

Greetings,
Nepomuk
Dec 10 '08 #2
micmast
144 New Member
You might also have to secure your apache installation:
first check if the TRACK / TRACE methods are enabled, this is true by default on a debian system. Not sure for a CentOS machine.
To check:
> nc localhost 80
TRACE / HTTP/1.0
via: hello
(enter a few times)

If the server returns that he doesn' tknow this function, you are good. If not you have 2 options:
1. add TraceEnable off to your configuration file
2. add a rewrite condition, also in your configuration file:
RewriteEngine on
RewriteCond %{REQUEST_METHOD} !^(GET|POST|HEAD)$
RewriteRule .* - [F]

When you install php, you might want to change a few settings, like magic quotes (first line of defense against cross site scripting & sql injections) and you might want to put it in safe mode (some functions however will not work, so you might want to verify what is best for you, more information can be found here: PHP: Safe Mode - Manual)

Next your mysql server, I would advice to take a good look at the standard tables that are inserted when installing mysql. You might not need all of them. Also create a very solid root account, with an insanely difficult password.
Last item make sure only connections from the localhost are allowed, unless you really really really need other hosts to communicate with your server.

As for system hardening, you could consider running your entire LAMP server in a chroot environment ( http://www.howtoforge.com/chrooted_d...ubuntu_desktop ), this will ensure that your users only have access to a system that has no extra data except the necesarry files to run the lamp server. An extra note on the chroot environment, please check that there are no executables that don't have the correct permissions set. If you have an executable that allows users to execute and become root for a moment, you might allow them to break the chroot ( How to break out of a chroot() jail - PenguinSecurityWiki )

That are the things that pop into my head... If I think of something I will add them

edit:
One more thing, SSH, put PermitRootLogin to No, default this is Yes I think, you don't want that. Also when using sudo, I'm not against it, but I prefer not the use sudo at all. If your root user has a very strong password, it is reasonably save, and whe you use "su" you know you really want to have root permissions, sudo is typed quickly and is not always required.
Dec 11 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
4968
by: Tom Jones | last post by:
I need to access databases on both win2k and Linux systems but I have to set up the DSNs under program control ... no uses using GUIs ... Has anyone done this? if so can we discuss it either in...
12
12393
by: HarveyB | last post by:
I would like to generate non-modal popup windows from ASP.Net code-behind. I have tried using Client Side scripting like "function Test(){ window.open('test.htm',_blank,...
0
1119
by: Michael Hauer | last post by:
Hi, First my system(s): We want to migrate one server from NT 4.0 to Linux (small company). Clients are NT + XP. The application is .NET 1.0 and all clients run 1.0 SP3. A network drive...
27
3830
by: Mike | last post by:
Open source programs in general suck pretty bad also. Here are some loose facts regarding why projects like Linux, PHP, MYSQL, and other open source programs suck: - Linux is simply a clone of...
9
647
by: Steve Buster | last post by:
All right, I have read every forum, newsgroup etc about this issue and no one seems to know how to fix it. I am getting a "Server Application Unavailable" exception running my .NET 1.1...
6
3762
by: Daniel Walzenbach | last post by:
Hi, I have a web application which sometimes throws an “out of memory” exception. To get an idea what happens I traced some values using performance monitor and got the following values (for...
2
6915
by: Jobs | last post by:
Download the JAVA , .NET and SQL Server interview with answers Download the JAVA , .NET and SQL Server interview sheet and rate yourself. This will help you judge yourself are you really worth of...
3
5710
by: Bruno LIVERNAIS | last post by:
Hi, We are currently installing a DB2 V9 ESE on a Linux server (RHEL4U4-x86_64). Installation runs successfully on each node. Database user environment is OK and the instance is well created. To...
0
6989
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7157
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7195
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6873
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7367
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
3088
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3078
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
644
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
285
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.