20 Linux Server Hardening Security Tips
20 Linux Server Hardening Security Tips
About
Forum
Howtos & FAQs
Low graphics
Shell Scripts
RSS/Feed
Securing your Linux server is important to protect your data, intellectual property, and time, from the hands of crackers (hackers). The system
administrator is responsible for security Linux box. In this first part of a Linux server security series, I will provide 20 hardening tips for default
installation of Linux system.
1. Use scp, ssh, rsync, or sftp for file transfer. You can also mount remote server file system or your own home directory using special sshfs and fuse tools.
2. GnuPG allows to encrypt and sign your data and communication, features a versatile key managment system as well as access modules for all kind of public key
directories.
3. Fugu is a graphical frontend to the commandline Secure File Transfer application (SFTP). SFTP is similar to FTP, but unlike FTP, the entire session is encrypted,
meaning no passwords are sent in cleartext form, and is thus much less vulnerable to third-party interception. Another option is FileZilla - a cross-platform client
that supports FTP, FTP over SSL/TLS (FTPS), and SSH File Transfer Protocol (SFTP).
4. OpenVPN is a cost-effective, lightweight SSL VPN.
5. Lighttpd SSL (Secure Server Layer) Https Configuration And Installation
6. Apache SSL (Secure Server Layer) Https (mod_ssl) Configuration And Installation
#5.1: SELinux
I strongly recommend using SELinux which provides a flexible Mandatory Access Control (MAC). Under standard Linux Discretionary Access Control (DAC), an
application or process running as a user (UID or SUID) has the user's permissions to objects such as files, sockets, and other processes. Running a MAC kernel
protects the system from malicious or flawed applications that can damage or destroy the system. See the official Redhat documentation which explains SELinux
configuration.
{userName}:{password}:{lastpasswdchanged}:{Minimum_days}:{Maximum_days}:{Warn}:{Inactive}:{Expire}:
Where,
1. Minimum_days: The minimum number of days required between password changes i.e. the number of days left before the user is allowed to change his/her
password.
2. Maximum_days: The maximum number of days the password is valid (after that user is forced to change his/her password).
3. Warn : The number of days before password is to expire that user is warned that his/her password must be changed.
4. Expire : Days since Jan 1, 1970 that account is disabled i.e. an absolute date specifying when the login may no longer be used.
www.cyberciti.biz/tips/linux-security.html 2/25
10/24/2013 20 Linux Server Hardening Security Tips
faillog -r -u userName
Note you can use passwd command to lock and unlock accounts:
# lock account
passwd -l userName
# unlocak account
passwd -u userName
root:x:0:0:root:/root:/bin/bash
If you see other lines, delete them or make sure other accounts are authorized by you to use UID 0.
www.cyberciti.biz/tips/linux-security.html 3/25
10/24/2013 20 Linux Server Hardening Security Tips
#11: Configure Iptables and TCPWrappers
Iptables is a user space application program that allows you to configure the firewall (Netfilter) provided by the Linux kernel. Use firewall to filter out traffic and allow
only necessary traffic. Also use the TCPWrappers a host-based networking ACL system to filter network access to Internet. You can prevent many denial of service
attacks with the help of Iptables:
# Turn on execshield
kernel.exec-shield=1
kernel.randomize_va_space=1
# Enable IP spoofing protection
net.ipv4.conf.all.rp_filter=1
# Disable IP source routing
net.ipv4.conf.all.accept_source_route=0
# Ignoring broadcasts request
net.ipv4.icmp_echo_ignore_broadcasts=1
net.ipv4.icmp_ignore_bogus_error_messages=1
# Make sure spoofed packets get logged
net.ipv4.conf.all.log_martians = 1
/usr
/home
/var and /var/tmp
/tmp
Create septate partitions for Apache and FTP server roots. Edit /etc/fstab file and make sure you add the following configuration options:
1. noexec - Do not set execution of any binaries on this partition (prevents execution of binaries but allows scripts).
2. nodev - Do not allow character or special devices on this partition (prevents use of device files such as zero, sda etc).
3. nosuid - Do not set SUID/SGID access on this partition (prevent the setuid bit).
Sample /etc/fstab entry to to limit user access on /dev/sda5 (ftp server root directory):
You need to investigate each reported file. See reported file man page for further details.
#16.1: Kerberos
Kerberos performs authentication as a trusted third party authentication service by using cryptographic shared secret under the assumption that packets traveling along
the insecure network can be read, modified, and inserted. Kerberos builds on symmetric-key cryptography and requires a key distribution center. You can make
remote login, remote copy, secure inter-system file copying and other high-risk tasks safer and more controllable using Kerberos. So, when users authenticate to
network services using Kerberos, unauthorized users attempting to gather passwords by monitoring network traffic are effectively thwarted. See how to setup and use
Kerberos.
www.cyberciti.biz/tips/linux-security.html 5/25
10/24/2013 20 Linux Server Hardening Security Tips
From 58.y.xxx.ww - 1 packet to tcp(8080)
From 59.www.zzz.yyy - 1 packet to tcp(22)
From 60.32.nnn.yyy - 2 packets to tcp(45633)
From 222.xxx.ttt.zz - 5 packets to tcp(8000,8080,8800)
---------------------- iptables firewall End -------------------------
--------------------- SSHD Begin ------------------------
Users logging in through sshd:
root:
123.xxx.ttt.zzz: 6 times
---------------------- SSHD End -------------------------
--------------------- Disk Space Begin ------------------------
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 450G 185G 241G 44% /
/dev/sda1 99M 35M 60M 37% /boot
---------------------- Disk Space End -------------------------
###################### Logwatch End #########################
See our quick tutorial which explains enabling and using the auditd service.
It is a good practice to deploy any integrity checking software before system goes online in a production environment. If possible install AIDE software before the
system is connected to any network. AIDE is a host-based intrusion detection system (HIDS) it can monitor and analyses the internals of a computing system.
Snort is a software for intrusion detection which is capable of performing packet logging and real-time traffic analysis on IP networks.
Other Recommendation:
Backups - It cannot be stressed enough how important it is to make a backup of your Linux system. A proper offsite backup allows you to recover from cracked
server i.e. an intrusion. The traditional UNIX backup programs are dump and restore are also recommended.
How to: Looking for Rootkits.
Howto: Enable ExecShield Buffer Overflows Protection.
Subscribe to Redhat or Debian Linux security mailing list or RSS feed.
Recommend readings:
In the next part of this series I will discuss how to secure specific applications (such as Proxy, Mail, LAMP, Database) and a few other security tools. Did I miss
something? Please add your favorite system security tool or tip in the comments.
267
126
Like 368
StumbleUpon
If you would like to be kept up to date with our posts, you can follow us on Twitter, Facebook, Google+, or even by subscribing to our RSS Feed.
Featured Articles:
Reply
www.cyberciti.biz/tips/linux-security.html 7/25
10/24/2013 20 Linux Server Hardening Security Tips
sir,
how to configure LDAP server(server side, client side) in UBUNTU linux plese tell me step by step
Reply
https://help.ubuntu.com/community/LDAPClientAuthentication
Google is your friend. I found the above link in less than 30 seconds. We Linux geeks like to be helpful. Most will tell you how to hunt, but most
won’t hunt for you, cook for you, and feed you too. :)
Reply
Great article.
Really wroth……
Reply
Reply
Reply
Reply
Though i am an active user in your forum, i never posted a comment on your blog.. but this post really tempted me to comment.
the post really rocks man.. Most of the things new to me..
Thanks for sharing.
Reply
#10 – Disable X-Windows. I think you meant to say edit /etc/inittab and set to run level 3 not 5.
Reply
Reply
@Ben,
It was a typo on my part. Runlevel 5 is for X and 3 is text based full network mode under CentOS / RHEL / Fedora etc.
Reply
Reply
www.cyberciti.biz/tips/linux-security.html 8/25
10/24/2013 20 Linux Server Hardening Security Tips
13 Toby October 30, 2009 at 5:25 pm
I’m not surprised that SSH is #1, but I am a little puzzled that there’s no mention of key-only authentication… or denyhosts, if password access is a requirement.
I’m personally skeptical about password aging – strength requirements are important, but strong passwords don’t get weaker over time.
Reply
Please see (#18 SSH ) – a direct link Top 20 OpenSSH Server Best Security Practices.
Reply
I usually don’t comment on blogs, but this post deserves it…great article! Thank you for sharing….
Reply
Reply
Your articles always have something special to read. Thanks for sharing.
Reply
Reply
I actually stronglt disagree with 6.1 and 6.2. 6.2 Especially. Here’s why (from experience as an IT manager)..
Suppose you put 6.0 (which I agree with), 6.1, and 6.2 in place and set the age of a password for 30 days. Then the user is forced to learn a new password.
After another 30 days they are forced to change but by this time the user is starting to forget the passwords because they are changing and can not reuse an old
one.
So, Mr User writes it on a sticky note and puts it where he can read it, right on his monitor.
See where I’m going with this? This will happen time and time again which creates more of a compromise to security and defeats the purpose.
Reply
Reply
Reply
Reply
www.cyberciti.biz/tips/linux-security.html 9/25
10/24/2013 20 Linux Server Hardening Security Tips
23 P Saint Amour October 31, 2009 at 3:56 am
I mention so many times to clients that they should set up and use SELinux in mission critical secure situations and they constantly ignore it.
It should be used without question in installations where you want and need an extremely hardened system.
Reply
Reply
Reply
I don’t agree with disabling ipv6. The switch must be done and ipv6 has been pretty well
tested until now, chances that some bad traffic will cause a buffer overflow is very low.
Reply
Excelent post…
Thanks for share your knowledge…
Reply
Reply
Hello,
This article great one and very useful for all sysadmins.One again gr8 article.
Thanks
Sreeraj.K.G
Reply
www.cyberciti.biz/tips/linux-security.html 10/25
10/24/2013 20 Linux Server Hardening Security Tips
Agreed. I never used Truecrypt, but Wikipedia pages gives pretty good information about security.
Reply
I disagree with the #7 disable root login. I agree that root logins should be disabled for things like ssh, forcing users to login using their credentials. Howerver I
think sudo makes a box less secure. If an account gets compromised and they have sudo access for root level work, all the attacker has to do is type sudo
whatever and away they go.
With having requiring them to su to root, you’re adding defense in depth. They might compromise bob’s account, but now they have to work harder to get into
root.
I think sudo is great for 1 off commands but as a hardening system it leaves a lot to be desired.
Reply
Lots of good information on hardening Linux. How about /etc/security/limits.conf and friends to control other security aspects of the Linux?
Reply
to clarify sudo is great for one off commands on personal computers, but not that great for production servers.
Reply
John wrote:
>Not really, how hard is to run xen under Linux?
For real? It’s harder than running vmware, vbox, qemu/kvm. Because for a start you need an appropriate xen kernel.
Reply
Perfect! Congratulations,
Friend, you always give greats articles to all we! Your article, it has been very important to i can build a more secure system!
I am from Brazil, and i am student in the Science Computer! But, your level of knowledge is very high!
Bye!
Ricardo Costa
Reply
Reply
Grateful :)
Thanks,
Gokul.
Reply
I’ve heard both sides of the root login/su debate. Personally I don’t like using sudo. I generally use set up a rather long root password and change it every other
www.cyberciti.biz/tips/linux-security.html 11/25
10/24/2013 20 Linux Server Hardening Security Tips
month or so. I agree with chris j that it adds another layer especially if you set up ssh etc correctly to disable root logins and such. Of course, I don’t run any large
servers so my experience most likely isn’t as large as some of the posters here.
Reply
hideaki wrote:
>John wrote:
>>Not really, how hard is to run xen under Linux?
>For real? It’s harder than running vmware, vbox, qemu/kvm. Because for a start you need >an appropriate xen kernel.
Oh, come on. With Debian or CentOS you need max 5 minutes to have Dom0 + DomU functional (and you don’t even have to know what you are doing, there
is a zillion howto’s on the web)
Reply
Great Article!! :)
Reply
Most of these tips are pretty much ubiquitous. Secure passwords (e.g. those found outside of hacker dictionaries), and mod_security or something similar for
your webserver are truly key. When confronted with a linux/UNIX machine, hackers will first try to penetrate among common username/passwords and scan for
vulnerabilities in common web applications. Prevent it before it occurs. If you can, setup public-key auth for all SSH related crap. If you’re using lighttpd, look for
mod_security like rules.
Anyways, one cannot implement all since each environment is different. Also surprised to not see a file intrusion detection system up. Also, securing your machine
isn’t enough, you want to keep at least daily backups. If you host your server and become a victim of being hacked. Don’t expect it to stop there, they will use
your machine as a zombie/bot to attack other machines. The ISP will shut your machine down, and you will have even a difficult time getting back to your data.
Make backups frequently and off-site. Data is truly of value, the machine it runs on isn’t.
Just my 2c.
Reply
Reply
OVZkernel RHEL
Reply
OVZkernel share kernel with its host and other vps operating systems. So you will not able to use all MIBs or iptables features.
Reply
As usual, thanks!!
Reply
It’s gr8..
Thx 4 sharing..
www.cyberciti.biz/tips/linux-security.html 12/25
10/24/2013 20 Linux Server Hardening Security Tips
Reply
Thanks for sharing tips for linux ……… Thanks Mr. Vivek Gite
Reply
Reply
Reply
Thanks alot for UBER tips…. Thanks Mr. Vivek, from Nixcraft to Cyberciti you keep them coming.
Reply
Reply
Not very useful for real production servers. Real servers (like the dozens I work with) are administered by 1-2 people accessing directly as root from local
network (that includes vpn access), not from the internet side. No need to eat your brain thinking and thinking about sudo, passwords, blah blah. Ah, btw…
automatic updates can only break your working system :) The rest, is just common sense. You can’t learn linux only by applying rules you read on a web page…
you learn linux after years, and maybe only then.
Reply
I do appreciate the effort that has been done to present this informative topic
please do inform me via e-mail regardig such security issues.
Many thanks
Eng. ahmed
Reply
Reply
Reply
Reply
Reply
www.cyberciti.biz/tips/linux-security.html 13/25
10/24/2013 20 Linux Server Hardening Security Tips
58 Andre April 25, 2010 at 10:12 pm
Reply
Could we have a post here for step by step configuration of LDAP (Centralized Authentication Service). And the usage.
Reply
Reply
Reply
I would choose to install grsecurity:http://grsecurity.net/download.php linux kernel patch anytime over “SELinux”
because it have much more paranoid-security options that would make SElinux look like a baby toy,
Reply
Cool! It will help a lot, especially to novice linux users that will make them look expert, as well as for newbies. Thanks so much!! More power!
Reply
Excellent article, however with the need for IPv6 fast approaching, telling users to disable it is like telling us to bury our heads in the sand.
I’ve seen this advice all over the internet, and it will very soon be not such a good idea.
I would suggest that instead of telling users to disable IPv6, let’s start learning about it, creating tools to deal with it and get our hands dirty using it.
Reply
@Ruben. Even if you only can access SSH from your lan, you should still disable root login. Just login using your own SSH key and become root (su). Also limit
the users that can become root (wheel users). So before someone can login root, he (or she) first have to crack two user accounts. But disable root login helps
also with the physical security.
About some other points. Passwords should not expire if you enforce strong passwords. The trouble is that users can only remember only so many passwords,
so if thay have to change password frequently, they’re gonna use the same password at other places.
In 2002 I had to strengthen the security for an e-commerce company. They kept the clear customer passwords in a database. You wouldn’t believe how many
email logins and passwords work. BTW: Passwords should be stored as hashes. Sending an email with a link to change the password is not different from a email
that shows you the passwords. However, a comprised database is dangerous. If I wanted it to, I could have read a lot of emails and collect even more sensitive
data like registration mails from websites that show you your password..
SE-Linux should be a standard installed with every Linux distribution. It makes it a bit harder to exploits bugs in code. That’s also valuable on workstations. Most
companies only secure the front door. If you break a window, you can go anywhere in the building. Hack a workstation and often you can access everything
within the LAN.
IPv6 should be disabled if you don’t have an IPv6 IP or services. If you have, you have to secure just like you secure an IPv4 network. I already use IPv6 within
every LAN I install. The main router (gateway) has an IPv6 bridge to my data center (which is IPv6 enabled) and from there they can connect to both IPv6
networks or IPv4 networks.
Reply
www.cyberciti.biz/tips/linux-security.html 14/25
10/24/2013 20 Linux Server Hardening Security Tips
There is a slight wording mistake in #1: Encrypt Data Communication, section 3 “Fugu is a graphical frontend to the commandline Secure File Transfer
application (SFTP)”. The acronym SFTP is misleading. SFTP is the “SSH file transfer protocol”, “Secure FTP” is something very different
(http://en.wikipedia.org/wiki/FTP_over_SSH#FTP_over_SSH_.28not_SFTP.29). Secure FTP encrypts only the control channel , the data channel stays
unencrypted.
Reply
It kills me how many people get their info “facts” from wiki…
Man.. doesn’t anyone watch CNN? wiki is poo.. not accurate.. it is user-defined.. users make mistakes… SFTP is NOT SSH… Agghhh!! (Charlie
Brown Scream…)
Reply
ANswer.. Get rid of the end user and hire someone who can remember a password..
Best practice is 60 or 90 day, 14 characters minimum, and complexity requiring minimum of – 1 upper, 1 lower, 1 alpha, 1 symbol, 1 numeric.
Remember password history..
Why because exploits move forward every day as do caps.. Each day a password remains static, is one more oppertunity given to comprimise your system
security and capture user information…
The problem w/ user passwords is that SO many users, use bank info, pins, etc…
Its a best practice… As yourself this.. If you are sued.. yes.. lawsuit.. What will you tell the prosecuting atty. when he asks if you used complexity requirements
and changes on passwords?
All the attorney of the guy suing you has to prove is negligence.. Because so many passwords have been compromised.. you not enforcing it could be cionsidered
negligence and could be a fatal loss to the suit..
Not saying it is right or easy.. But it’s best practice and it will help keep you and your company (did I mention you) out of a bind if legal issues arise…
Reply
Really a very good and concise article that is informative and addresses various security issues.
Very well written.
Thank you for writing and posting this article.
Reply
Reply
Nice round up of some common server hardening techniques. While not specific to the server, I would add having a web application firewall, e.g. mod security or
something similar. According to SANS, most exploits these days happen via web applications. Even with these tips (SELinux excepted), attackers can often
setup shell kits, spam bots or similar tools.
Also, never just rely on the hardening. Using something like Nessus to audit the server. With a professional feed, you can actually audit against a variety of
policies, such as the Center for Internet Security guidelines.
Reply
Good article
Reply
www.cyberciti.biz/tips/linux-security.html 15/25
10/24/2013 20 Linux Server Hardening Security Tips
73 jef October 14, 2010 at 12:28 am
Reply
Wow! This is an amazing article. Lots of things about securing a server that I either overlooked, or simply forgot about! You rock! =0)
Reply
@A G33k
If you get rid of the end user who cannot remember password, you will fire 99% of people in your company. Not a very good idea? Everybody are using yellow
stickers, excel files etc. There is so many passwords to rember, most of for absolutely pointless accounts, which nobody cares.
Reply
Reply
Hi,
Tried #12 Kernel/sysctl hardening, but ‘sysctl -p’ comes up with “error: ‘kernel.exec-shield’ is unknown key” on Ubuntu 10.04.1 LTS as well as Mint 9 KDE.
Any ideas?
TIA
Reply
* For ssh disable password authentication, using public keys (on authorized_keys) is safer.
* Don’t disable IPv6, learn about it, use it, promote it.
* Limit the maximum number of connections with a firewall, using iptables and ip6tables.
Reply
Reply
Reply
I reviewed the comments and nobody seems to be bothered by one little fact… Hackers are not Crackers… It’s kinda disappointing to read such a “confusion”
on a Unix dedicated site. Not only it is not a confusion, but it is “clarified”, openly associating and presenting the word “cracker” as a synonym for “Hacker”.
Reply
Sudo is crap for security period except leaving an audit trail… which any user with sudo access can get rid of trivially. Lets say you have 5 admins each who
needs root level access. With sudo that means each user’s password is another potential compromise of root level privileges. There are things you can do to help
www.cyberciti.biz/tips/linux-security.html 16/25
10/24/2013 20 Linux Server Hardening Security Tips
with that like using rootpw or disabling the ability to get a true shell with sudo but this breaks much of sudos functionality. Sudo is very good at offering a false
sense of security and accountability of LEGITIMATE users. It does very little for non-legitimate users.
Reply
perfect. I was searching how to disable the root access. I love this site. I can’t believe I didn’t find it sooner. I switched from shared web hosting to vps web
hosting and I love it.
Thanks!
Reply
Well, Christopher… I think if, God forbid, the user account is compromised then you can simply login as root and delete it, along with it’s ~/ directory. But if you
disable root access… I guess you’d have to reinstall the OS.
Also, setting the “noexec” flag in fstab is a very smart move. Especially for data partitions (why would you wanna run binaries from a data partition anyway ?
Programs should have no business there). I thought this flag also applied for scripts. Hmmm….
Reply
Hi Sir, Am fan to your article.. Really these are very excellent sessions.. we never get this from any other books.. Really Am so happy and we are improving our
confidential levels by following your articles.. One small request, Why dont you keep an article on Solaris server issues.. Because now a days, both unix and linux
are growing popular across the world.. And so many administrators are working in dual modes (LINUX and UNIX) . So, if the send an article based on linux
and unix(solaris) then, so many administrators feel much better..
Thanks
Reply
Hi Sir,
I have been trying to implement OpenLDAP server in CentOS5.4 for the past 10 months. But, till i haven’t implemented. I studied and gathered so many books
and articles.. even though am not succeeded. So, could you send openldap server configuration article in CentOS5. Then i can follow your help to complete the
task..And i need exactly what is ldap ? why for Ldap? where to Implement ldap ?
I have so many doubts are there on ldap scenario. And how can join windows client to linux openldap server ? . If joins, how to do that ? .. So, could you
explain detailedly…
thanks,
Ramakrishna – krrish
Reply
I have heard the arguments for and against #7, disable root login, and am for it…
But you never tell me HOW to. :D
Reply
debian apt-get may break system if cannot use /tmp. Tmp may be set noexec, nosuid, etc.
To harden, may need to write pre-process script and post-process scriipt after
apt-get upgrade.
Linux hostnamm 2.6.39-3.slh.xxx-aptosid-xxx64 #1 SMP PREEMPT Sat Jul xxx 2011 x86_64 GNU/Linux
www.cyberciti.biz/tips/linux-security.html 17/25
10/24/2013 20 Linux Server Hardening Security Tips
Great article. Advanced persistent threats and rootkits. Kernel is the last line
of defense.
Reply
Reply
Just another one of those valuable well written article. Thank you vivek for sharing this with the rest of us.
Reply
Is this hardening checklist good for ALL Linux distributions, such as CentOS, Fedora, Debian, Ubuntu, etc………
thanks,
Reply
Venkat
Reply
thank for sharing. it the best best practice for me. thank you very much Vivek
Reply
ThanQ
Reply
need to know which file we need to edit or how we can set password rules in redhat such as “password should include alphanumeric,special characters,numbers
etc.
Thanks
Renjith
Reply
Reply
www.cyberciti.biz/tips/linux-security.html 18/25
10/24/2013 20 Linux Server Hardening Security Tips
I want to show appreciation to this writer just for bailing me out of this type of issue. Right after searching throughout the world wide web and finding ways which
were not helpful, I believed my life was gone. Living without the approaches to the difficulties you have fixed by means of your entire blog post is a crucial case,
and those that would have in a negative way damaged my career if I hadn’t encountered your web blog. Your ability and kindness in maneuvering all the details
was crucial. I’m not sure what I would have done if I hadn’t come across such a subject like this. It’s possible to at this time relish my future. Thank you very
much for the reliable and amazing guide. I won’t be reluctant to refer your web blog to anyone who needs guidelines about this topic.
Reply
You need to triage your recommendations for how much they cost to do (in terms of time):
Sites with thousands of servers and understaffed admins can’t possibly do all of this, and even on smaller sites with only a few dozen boxes, there needs to be
some focus on which of these offer the best bang for the amount of time spent.
#1: Encryption – This is good, but the suggestion to remove xinetd wholesale is generally bad, ideally use chef to only enable xinetd where needed.
#3: One service one box – This is a good goal, much more achievable in the virtualization era. Exceptions can be made, particularly with lightweight internal
services.
#6: Password policy – Largely you have to do this, auditors expect it. I share the concerns about rotation leading to sickies on monitors, but I know I won’t win
that argument with auditors.
#7: Disable root login – Yes, remote root needs to be disabled to prevent non-reputability, I actually agree here.
#9: Disable services – Very good. Do this. Highly likely that unneeded and unmaintained services lead to actual security compromise.
#10: Disable X11 – Yep, unneeded on servers generally, don’t install. Some software installation requires it, which is annoying and you’ll need to make
exceptions for on limited case-by-case basis.
#11: Sysctl hardening – Good and reasonably cheap. Use chef.
#15: Disable unwanted SUIDs and SGIDs – I agree, time well spent, reduces attack surface.
#17: Logging and Auditing – Past some point this just becomes using a loghost with enough disk to retain logs, and the noise level becomes insane. I wouldn’t
spend too much time watching all the logs all the time, although its nice if you’ve got a junior admin with enough free time to watch for events. In PCI situations
you have to not only watch this, but respond and it becomes mandatory.
#2: Removing/auditing RPMs – This became laughable to me a decade ago, nearly a complete waste of time.
#5: SElinux – Also largely a waste of time, and ongoing maintenance nightmare, most actual intrusions would be prevented by getting easier stuff right
#8: Locking down BIOS and Grub – Servers should be secure in datacenters, physical access means a compromise anyway and grub passwords get in the way
of administration
#13: Seperate Partitions for Everything – Oh, FFS, I have a job to do. Complete waste of my time.
#14: Turn off IPv6 – this is laughable and becoming more indefensible now
#19: IDS – Also mostly a source of noise. I suggest using fail2ban to automate iptables blocking in response to attacks, which does something useful (e.g. ssh
attacks actually chew up your cpu, and fail2ban gets that back).
#20: Encryption of files – largely a waste of time within the enterprise, other than *very* targetted systems that are high-value targets. Just get your account
management right.
USE CHEF, PUPPET OR SOME OTHER CONFIG MANAGEMENT ENGINE TO ENFORCE POLICY
And yes, I wrote that in all CAPS for a reason. That should be policy #0 that comes before all else.
Reply
Excellent article!
Reply
Reply
www.cyberciti.biz/tips/linux-security.html 19/25
10/24/2013 20 Linux Server Hardening Security Tips
101 nbasileu January 11, 2012 at 1:38 pm
#1
7. Nginx SSL
http://wiki.nginx.org/HttpSslModule
Reply
Well , one forgot about 8080 , port needed in some apps like ISPConfig or whatever.
Having ssh server enabled , we can disable 8080 via port forwarding in router, but use a ” backdoor ” aka tunnelling needed ports through ssh :
ssh -D localhost:8080 [email protected].
Put firefox using socksV5 127.0.0.1 and voila ! , of course ,port number can vary !
Let Mysql as default to listen only 127.0.0.1 ,enforce apache with mod_security and mod_evasive,check website folders not to be 777,and if using wordpress
look for a good firewall or go write yourself a decent one to prevent sql injection.
And keep it in mind ,everything made by humans will be cracked by humans , it is just a matter of time !
Sincerly , Gabriel
Reply
Reply
One more thing we need to consider as a security treat, some softwares have default UserID and Password like phpmyadmin and other softwares, after
installation of this kind of software’s we need to take care of userID and Password.
Reply
Hello Dear,
Reply
Reply
Reply
Reply
Very very very very usefull info. It help me a lot. Many thanks to you
Reply
www.cyberciti.biz/tips/linux-security.html 20/25
10/24/2013 20 Linux Server Hardening Security Tips
Reply
Reply
What about setting up a catch-all mailbox for all the root email on your servers? root’s email does not normally get read on a lot of sites. Reading one mailbox is
better than logging into every server to check status.
Reply
I love you, Vivek. You save me everytime I have issues or questions. You make me look like an elite linux user and server admin. Thank you so much for your
hard work and please do keep on keeping on.
Reply
Don’t forget GRSec patch for Kernel, mod_security for Apache and suhosin patch for PHP.
Reply
Gr8 post.
Many thanks to uploader.
Reply
Reply
Great read! Thanks for taking the time to put this out there.
Reply
Everything in one place and so neat…Thanks for sharing such a useful info…Thanks in tons….
Reply
Hey thanks for writing up an article on securing server. Today I had a lot of hacking on my vps server and I couldn’t access any of the sites. Anyway, I had to go
in and kill apache via ssh and had to switch it off for 12 hours until the hacking went away. I later realised that my wordpress sites were getting a whacked via the
login path.
Reply
Systems Administrator
Disney Interactive
Reply
www.cyberciti.biz/tips/linux-security.html 21/25
10/24/2013 20 Linux Server Hardening Security Tips
121 suresh September 16, 2013 at 9:18 am
Hi,
Great Article… :)
Thanks
Reply
Great post!
Reply
Leave a Comment
Name *
E-mail *
Website
You can use these HTML tags and attributes for your code and commands: <strong> <em> <ol> <li> <u> <ul> <blockquote> <pre> <a href="" title="">
Submit
Tagged as: bastille linux hardening, harden tcp ip stack, Hardening centos, Hardening debian, Hardening Linux, hardening red hat, Hardening rhel, Linux, linux kernel
hardening, linux security, Linux Security Kernel Enhancements, linux security modules, Redhat Linux Hardening, Security
Next post: Linux / Windows Application For Prevention Of RSI (Repetitive Strain Injury)
[email protected] Sign Up
www.cyberciti.biz/tips/linux-security.html 22/25
10/24/2013 20 Linux Server Hardening Security Tips
nixCraft
Like
Related Posts
www.cyberciti.biz/tips/linux-security.html 23/25
10/24/2013 20 Linux Server Hardening Security Tips
www.cyberciti.biz/tips/linux-security.html 24/25
10/24/2013 20 Linux Server Hardening Security Tips
OS X Mountain Lion 10.8 Set Apache and PHP Web-Server
Clear Squid Proxy Cache And Re-create the Cache Directories
HowTo: Pronounce Mac OS X
Fedora Linux: Restart / Stop / Start DHCPD Server Command
Linux: Find Out What Is Using TCP Port 80
HowTo: OS X Take a Screenshot On My Mac Desktop
CentOS / RHEL: Install KornShell (KSH)
Linux / Unix: Shell Script Find Out In Which Directory Script File Resides
Bash: Display Web Page Content In Terminal
©2004-2013 nixCraft. All rights reserved. Cannot be reproduced without written permission.
Privacy Policy | Terms of Service | Questions or Comments | Copyright Info | Sitemap
www.cyberciti.biz/tips/linux-security.html 25/25