Setting up a secure Linux server
Other Ideas
My next thoughts would be how to keep a close check on the filesystem. You might want to create MD5 checksums of your key files to compare them later if you suspect a compromise. Alternatively, you could install a filesystem integrity check, such as AIDE (Advanced Intrusion Detection Environment), to keep an eye on filesystem changes.
You might also want to configure iptables to catch any services that fire up unexpectedly through either conspiracy or misconfiguration.
Another interesting option for securing your system is port knocking [6]. Port knocking lets you close off your SSH server port to the outside world – switch off pings and make your server completely invisible. Then, the only way to wake up the SSH Server is to connect to a predefined sequence of ports.
If you are offering your users remote access through SFTP, you might want to lock down their access by forcing them to work within their home directories and not to run other system commands. Simply configure an SFTP chroot of sorts [7].
You might also consider employing a tool that automatically examines and locks down your system, reporting on security issues. Tools such as Bastille Linux or Lynis provide this kind of securing auditing service.
The upside of tools like Bastille Linux and Lynis is they speed up the process of security hardening and make it so you don't need to know all of the ins and outs of what you are securing in great detail. The downside is that sys admins become less interested in understanding security at a deeper level and ultimately risk losing the benefits of learning how to secure systems themselves. It's very easy to type Y
and accidentally render a system useless if you don't understand exactly what the application is asking you.
It Never Ends
Clearly security isn't just about the server configuration. I could have gone into much further detail about configuring your server and looked at other parts of the network as well. What about checking for dangerous files with setuid permissions? You would only want to allow a select few files to have permissions that mean the user running the file inherits the permissions of the file.
Try tinkering with this command-line example, if I've caused you concern in this regard:
# find / -xdev \( -perm -4000 \) -type f -print0 | xargs -0 ls -hal
With this command we can check which files, on our entire system, are configured with permission 4000 or the SUID bit
(which will show up as s
in the file's permissions after a directory listing). You can remove any nasty surprises that show the s
bit as being present with:
# chmod -s /home/chrisbinnie/nasty_file
To protect my filesystems further, I might consider SELinux at this stage of the build too. I might have also go secret-agent-style and have a peek at the US National Security Agency's recommendations [10].
When putting Apache on this box, I would immediately hide the cgi-bin
directory and change the ServerTokens
settings to Prod
. I also would encourage a quick refresher on hardening Apache by reading the excellent article at the Geekflare site [11].
The never-ending list of security checks simply keeps on going. If you want to read further, look at OpenSCAP from the National Institute of Standards and Technology (NIST) [12]. OpenSCAP works on "automatically verifying the presence of patches, checking system security configuration settings, and examining systems for signs of compromise."
I hope this article has piqued your interest enough to keep on exploring the fascinating side of system security. It is a good idea to build and configure your server systems with a close eye on security if you want to return at a later date and find them working in the same way that you left them.
Infos
- Logwatch: http://www.logwatch.org/
- "Lean on Logwatch" by Chris Binnie, ADMIN, issue 25, 2015: http://www.admin-magazine.com/Archive/2015/25/Lean-on-Logwatch/%28language%29/eng-US
- How to Secure Postfix on Ubuntu Server: http://askubuntu.com/questions/418340/how-to-secure-postfix-on-ubuntu-server
- "Revealed: The Top 25 Most Common Passwords": http://news.sky.com/story/1412124/revealed-the-top-25-most-common-passwords
- "Using Cracklib to Require Stronger Passwords": http://thegarywilson.com/blog/2006/using-cracklib-to-require-stronger-passwords/
- "Protect Your Network with Port Knocking" by Chris Binnie, ADMIN , issue 23, 2014: http://www.admin-magazine.com/Archive/2014/23/Port-Knocking
- "Limiting Access with SFTP Jails on Debian and Ubuntu": https://www.linode.com/docs/tools-reference/tools/limiting-access-with-sftp-jails-on-debian-and-ubuntu
- Bastille Linux: http://bastille-linux.sourceforge.net/
- Lynis: https://cisofy.com/lynis/
- NSA Guide for Secure OS Configuration: https://www.nsa.gov/ia/mitigation_guidance/security_configuration_guides/operating_systems.shtml
- "Apache Web Server Hardening and Security Guide": http://geekflare.com/apache-web-server-hardening-security/
- OpenSCAP Portal: http://www.open-scap.org/page/Main_Page
« Previous 1 2 3
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.
News
-
Fedora 40 Beta Released Soon
With the official release of Fedora 40 coming in April, it's almost time to download the beta and see what's new.
-
New Pentesting Distribution to Compete with Kali Linux
SnoopGod is now available for your testing needs
-
Juno Computers Launches Another Linux Laptop
If you're looking for a powerhouse laptop that runs Ubuntu, the Juno Computers Neptune 17 v6 should be on your radar.
-
ZorinOS 17.1 Released, Includes Improved Windows App Support
If you need or desire to run Windows applications on Linux, there's one distribution intent on making that easier for you and its new release further improves that feature.
-
Linux Market Share Surpasses 4% for the First Time
Look out Windows and macOS, Linux is on the rise and has even topped ChromeOS to become the fourth most widely used OS around the globe.
-
KDE’s Plasma 6 Officially Available
KDE’s Plasma 6.0 "Megarelease" has happened, and it's brimming with new features, polish, and performance.
-
Latest Version of Tails Unleashed
Tails 6.0 is based on Debian 12 and includes GNOME 43.
-
KDE Announces New Slimbook V with Plenty of Power and KDE’s Plasma 6
If you're a fan of KDE Plasma, you'll be thrilled to hear they've announced a new Slimbook with an AMD CPU and the latest version of KDE Plasma desktop.
-
Monthly Sponsorship Includes Early Access to elementary OS 8
If you want to get a glimpse of what's in the pipeline for elementary OS 8, just set up a monthly sponsorship to help fund its continued existence.
-
DebConf24 to be Held in South Korea
Busan will be the location of the latest DebConf running July 28 through August 4