TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Linux Hardening Guide

460 pointsby FlyMoreRocketsover 4 years ago

40 comments

simonjgreenover 4 years ago
As a *nix sysadmin since before Google was a thing, I find articles like this frustrating and arguably dangerous.<p>They lay out a set of &quot;rules&quot; the author has collated as a dogmatic doctrine that only a fool would not follow. But they provide no &quot;why&quot;, take absolutely no context in to account, and talk only about their perceived upsides.<p>Anyone reading this should take each point as &quot;here&#x27;s a possible thing you should go and research yourself&quot;, because there are consequences to most of these rules.<p>I&#x27;m not saying anything they&#x27;ve written is wrong (though there is a lot of unsubstantiated opinion there), just that you should learn what any of these changes truly do before implementing them AND that your particular context is really important.<p>Edit:<p>There is a disclaimer at the top which mustn&#x27;t be forgotten while reading.<p>&gt; DISCLAIMER: Do not attempt to apply anything in this article if you do not know exactly what you are doing. This guide is focused purely on security and privacy, not performance, usability, or anything else.<p>I do appreciate people putting work into producing this sort of content, but I think the article could be improved by phrasing the various steps as suggestions and perhaps linking out to more detailed documentation on the &quot;why&quot; elsewhere.
评论 #25591249 未加载
评论 #25591394 未加载
评论 #25591106 未加载
评论 #25593702 未加载
评论 #25591281 未加载
评论 #25592770 未加载
评论 #25591090 未加载
评论 #25590913 未加载
评论 #25593875 未加载
评论 #25612070 未加载
评论 #25591357 未加载
评论 #25590912 未加载
px43over 4 years ago
Some omissions IMO: never let people SSH in with a password, and for the love of god, stop leaving private SSH keys on servers. Privat SSH keys should never leave your physical proximity. They should be on your laptop, or desktop, or your yubikey, but never on servers. Also SSH agent forwarding is the devil. Don&#x27;t do it.<p>Lots of really braindead advice in there too, like disabling RDRAND because there might be a backdoor.. come on.. even Linus knows that&#x27;s obvious bullshit.[1]<p>[1] <a href="https:&#x2F;&#x2F;nakedsecurity.sophos.com&#x2F;2013&#x2F;09&#x2F;11&#x2F;rudest-man-in-linuxdom-rants-about-randomness-we-actually-know-what-we-are-doing-you-dont&#x2F;" rel="nofollow">https:&#x2F;&#x2F;nakedsecurity.sophos.com&#x2F;2013&#x2F;09&#x2F;11&#x2F;rudest-man-in-li...</a>
评论 #25591006 未加载
评论 #25590915 未加载
评论 #25590688 未加载
评论 #25590480 未加载
评论 #25590543 未加载
评论 #25590462 未加载
评论 #25592878 未加载
评论 #25590708 未加载
评论 #25591045 未加载
评论 #25599303 未加载
评论 #25590677 未加载
评论 #25590736 未加载
评论 #25599165 未加载
rococodeover 4 years ago
This list is cool, but I think it would be more useful with some quick notes on side effects. I think all but the most hardcore Linux lovers won&#x27;t have enough breadth and depth to understand the full ramifications of many of these config changes.<p>I&#x27;m no Linux expert but even having used it for a fair number of years, I only have a shallow understanding of most of the things that are tweaked here, if I&#x27;ve even heard of them at all. For example, it says &quot;kernel.kexec_load_disabled=1&quot;, and points out the threat which I can understand, but I don&#x27;t know what that&#x27;s used for in the first place. Perhaps it isn&#x27;t really ever used for anything, but it&#x27;d be nice to be told that, because my initial line of thinking is that these defaults must be defaults for a reason and that makes me hesitant to actually make any of the changes.
xyzzy123over 4 years ago
Most of the ideas are good but I think you need a pretty big team to sustain your systems if you&#x27;re flipping all the security switches to non-default values.<p>It would be fine as a one-time activity but it creates an ongoing stream of work to deal with breakages, particularly during upgrades.<p>Your OS ends up in a configuration that no upstream devs have tested compatibility for and you end up shouldering that for each component of your workload.<p>The recommended security options (given you have opted to tweak all the things) change over time as well and that creates additional work.<p>I think for many (most?) teams choosing a minimalist OS where an upstream does this kind of maintenance (say COOS or BottleRocket in container world) will produce better real-world results.
评论 #25590667 未加载
based2over 4 years ago
<a href="https:&#x2F;&#x2F;static.open-scap.org&#x2F;ssg-guides&#x2F;ssg-fedora-guide-index.html" rel="nofollow">https:&#x2F;&#x2F;static.open-scap.org&#x2F;ssg-guides&#x2F;ssg-fedora-guide-ind...</a><p><a href="https:&#x2F;&#x2F;wiki.debian.org&#x2F;Hardening" rel="nofollow">https:&#x2F;&#x2F;wiki.debian.org&#x2F;Hardening</a><p><a href="https:&#x2F;&#x2F;wiki.gentoo.org&#x2F;wiki&#x2F;Hardened_Gentoo" rel="nofollow">https:&#x2F;&#x2F;wiki.gentoo.org&#x2F;wiki&#x2F;Hardened_Gentoo</a><p><a href="https:&#x2F;&#x2F;access.redhat.com&#x2F;documentation&#x2F;en-us&#x2F;red_hat_enterprise_linux&#x2F;8&#x2F;pdf&#x2F;security_hardening&#x2F;Red_Hat_Enterprise_Linux-8-Security_hardening-en-US.pdf" rel="nofollow">https:&#x2F;&#x2F;access.redhat.com&#x2F;documentation&#x2F;en-us&#x2F;red_hat_enterp...</a><p><a href="https:&#x2F;&#x2F;documentation.suse.com&#x2F;sles&#x2F;12-SP4&#x2F;single-html&#x2F;SLES-hardening&#x2F;" rel="nofollow">https:&#x2F;&#x2F;documentation.suse.com&#x2F;sles&#x2F;12-SP4&#x2F;single-html&#x2F;SLES-...</a>
chris_wotover 4 years ago
This guide is concerning for the following reasons:<p>* blithely states that systemd is not secure, uses lines of code in an unit system as a security measure and makes claims not substantiated about it.<p>* recommends musl and misleadingly states number of CVEs as some sort of security metric. Completely overlooking that glibc was created in 1987 and opposed to musl which was released in 2011.<p>* ignores the fact that a lot of effort had gone into hardening openssl, and seems to think supporting OS&#x2F;2 and VMS equates to bad code security<p>* seems to misunderstand the purpose of long-term support kernels, which rather ironically contradicts there first point about frozen updates... author should do some basic reading here, which directly contradicts the states there ate only two releases of kernels stable and LTS (there are actually four categories of releases, and don’t necessarily happen for security reasons): <a href="https:&#x2F;&#x2F;www.kernel.org&#x2F;category&#x2F;releases.html" rel="nofollow">https:&#x2F;&#x2F;www.kernel.org&#x2F;category&#x2F;releases.html</a><p>I am still reading through it, there are interesting points made but I’m definitely taking it with a grain of salt given the above!
ikureiover 4 years ago
&gt; Linux is not a secure operating system. [Click link for an explanation by the same author]<p>&gt; There is no strong sandboxing in the standard Linux desktop. [...] This is in contrast to other desktop operating systems such as macOS or Windows 10 [...]. Windows automatically sandboxes UWP applications and provides the Windows Sandbox utility for non-UWP applications.<p>Is this actually fair? Windows Sandbox is not that different from using docker, or even better a VM, is it? It&#x27;s great that UWP apps are sandboxed, but they&#x27;re a minority of the apps people use.<p>I don&#x27;t get how Windows gets a point over Linux here. Running all or most apps in a sandbox without the user even noticing improves security, but neither OS really do that effectively. Windows Sandbox is cool, and Linux doesn&#x27;t have something like that out of the box, but a VM is easy to install and create no?
评论 #25593294 未加载
评论 #25592123 未加载
评论 #25591928 未加载
评论 #25596930 未加载
评论 #25591920 未加载
评论 #25592235 未加载
3npover 4 years ago
While I did not read this properly yet, it seems like a good primer.<p>There is also a great set of ansible playbooks and roles that should cover this and more that is a good base for Linux servers: <a href="https:&#x2F;&#x2F;github.com&#x2F;dev-sec&#x2F;ansible-collection-hardening" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;dev-sec&#x2F;ansible-collection-hardening</a>
nerdbaggyover 4 years ago
I’m ehhh about the musl suggestion. I spent way to long finding problems that were related to musl
评论 #25593778 未加载
trinix912over 4 years ago
&gt; If possible, your timezone should be set to &quot;UTC&quot; and your locale and keymap to &quot;US&quot;.<p>Is there any special reason why other values would be less secure?
评论 #25590772 未加载
viraptorover 4 years ago
I&#x27;ve got mixed feeling about this page.<p>1. It does list some completely valid options which are good to know. All of them are interesting both from the perspective of learning about more Linux internals and actually locking down access where needed.<p>2. It mixes security and privacy. Some privacy things may be interesting, but going as far as removing your machine-id? What&#x27;s the scenario here exactly?<p>3. It tells you what you can do, but often doesn&#x27;t say why. What&#x27;s the threat model? It bounces between things that could be useful for the desktop and for the server. If you&#x27;re protecting yourself at home, what exactly does blocking ICMP provide you, given it&#x27;s likely both a flat network and you&#x27;re registered in both upnp and mdns?<p>4. Some points I find really questionable: It says to avoid distros with systemd, however systemd was the first one to really bring service sandboxing to the masses. So many issues could be avoided if we used PrivateTmp years ago. Some points are really bad: Avoiding distros that freeze packages (I guess vs rolling distros) is not a trivial change and is not obviously more secure.<p>5. <a href="https:&#x2F;&#x2F;xkcd.com&#x2F;1200&#x2F;" rel="nofollow">https:&#x2F;&#x2F;xkcd.com&#x2F;1200&#x2F;</a> - Sure you can put all of those extra options in kernel boot, the extra layers of service separation, spend time hiding identifiers and network options. Unless you&#x27;re specifically targeted, nobody will ever try that. You&#x27;ll be owned by some XSS which pulls your login cookie - and the list doesn&#x27;t even mention Firefox tab containers which can separate that content. Or if someone&#x27;s targeting developers, your SSH key will get extracted - and the post doesn&#x27;t even mention hardware SSH keys.<p>Overall it reminds me of CIS policies. &quot;Here&#x27;s a CIS certified docker image. It has aida and tcpwrapper on it, because security.&quot;
评论 #25590453 未加载
评论 #25590483 未加载
评论 #25591996 未加载
jmnicolasover 4 years ago
There&#x27;s a saying when you walk the Camino De Santiago that you shouldn&#x27;t worry about your next meal or bed because the Camino will provide.<p>I notice it is also true about HN.<p>Yesterday I was researching about Linux security and was disappointed by an eBook on the subject. Today HN has provided :)<p>Thanks HN, see you next year.
评论 #25590888 未加载
grapeli23over 4 years ago
I missed? Such an important was not mentioned<p>NoNewPrivileges=yes<p>&quot;A new system.conf setting NoNewPrivileges= is now available which may be used to turn off acquisition of new privileges system-wide (i.e. set Linux&#x27; PR_SET_NO_NEW_PRIVS for PID 1 itself, and thus also for all its children). Note that turning this option on means setuid binaries and file system capabilities lose their special powers. While turning on this option is a big step towards a more secure system, doing so is likely to break numerous pre-existing UNIX tools, in particular su and sudo.&quot;
signa11over 4 years ago
there is no threat model described here afaics. seems pretty shallow <i>imho</i>
评论 #25590562 未加载
评论 #25590549 未加载
4oo4over 4 years ago
I think everyone with valid criticisms of this should file an Github issue, I&#x27;m definitely planning to, because of these things:<p>- Lots of discussion on X11 security issues without any mention of wayland<p>- Not on the Linux page, but they recommend iOS as a secure OS, which is total bullshit given how many failures we&#x27;ve seen with serious bugs&#x2F;vulns put into production. I can&#x27;t even remember how many times I&#x27;ve read about bugs in Safari, Whatsapp or some other app that can be chained to get kernel-level privileges. Remember the Jeff Bezos hack?<p>- No discussion of threat models<p>- Focusing on academic&#x2F;technical arguments and not looking at real-world malware ecosystems&#x2F;exploits (or: why there is orders of magnitude more malware for Windows than Linux)<p>- Memory safe languages - Linux is totally exploring a way to use rust for parts of the kernel, and Windows is still probably 99% C&#x2F;C++<p>I&#x27;m all the more confused by this guy since he&#x27;s a whonix developer, this almost sounds like a Microsoft employee based on how little scrutiny he applies to Windows...<p><a href="https:&#x2F;&#x2F;github.com&#x2F;madaidans-insecurities&#x2F;madaidans-insecurities.github.io&#x2F;issues" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;madaidans-insecurities&#x2F;madaidans-insecuri...</a>
tutfbhufover 4 years ago
&gt; Configure a cron job or init script to update your system daily.<p>He recommends daily automated updates. This is quite dangerous from my personal experience in various distributions. An update might break your system or might put it into a vulnerable state. I very much prefer regular manual updates, as it allows me to read release notes, bug reports and manual user intervention instructions before update.
评论 #25591636 未加载
评论 #25591749 未加载
wantgunsover 4 years ago
The blog mentions the ill usage of OpenSSL in favour of LibreSSL. At the same time, right now the devs at Gentoo are having a heated discussion to discontinue LibreSSL support.
ch0I9daAiOover 4 years ago
Question is, why not run Lynis for example and research the output it gives you? It follows along the same lines of no password login for ssh, no x11 fowarding, etc.
lrossiover 4 years ago
&gt; fixes for most security vulnerabilities are not able to be backported to LTS kernels<p>This is nonsense.
INTPenisover 4 years ago
I like this, very good reference material.<p>But as the disclaimer notes, this should not be followed blindly. It&#x27;s sort of aimed at a niche audience because imho you should know what everything in that guide does, or at least know how to look it up, before applying it.<p>Also I feel that the overhead added by not using systemd creates a lot of attack surface too. So that&#x27;s a difficult trade off to consider.<p>This is a rabbit hole of a debate but I&#x27;m interested in comparing the security trade offs of using for example RHEL with systemd where you get properly packaged SElinux policy for all your packages, and using Gentoo without systemd where you get no SElinux policy packaged at all and you have to write and maintain a bunch of init scripts.<p>(And before anyone chimes in, I know RHEL has had to make compromises in their SElinux packaging but at least it&#x27;s there and you have the option to build upon it)<p>I personally prefer having the systemd+selinux option over any alternative. Because ease of administration is also a factor that influences security in the long run.
perlgeekover 4 years ago
This is a nice collection of options that you have, but you should evaluate each of them very carefully before actually implementing them.<p>Switch to libc to musl? You need to talk to the application developers first to see if their applications work on musl. This step alone requires some extensive testing; I&#x27;m sure some of the other steps do as well.
BOOSTERHIDROGENover 4 years ago
For average joe using ubuntu vps, what is the safest guide in this list that can be applied?
cuillevel3over 4 years ago
Awww, does anyone remember the Linux Administrator&#x27;s Security Guide (<a href="https:&#x2F;&#x2F;seifried.org&#x2F;lasg&#x2F;" rel="nofollow">https:&#x2F;&#x2F;seifried.org&#x2F;lasg&#x2F;</a>)?<p>It was such a valuable resource in 2001.
nottrobinover 4 years ago
There&#x27;s no mention of snaps in the sandboxing section. This is a shame, I&#x27;d like to hear the author&#x27;s analysis of its sandboxing.<p>As far as I&#x27;m aware, it is stricter on providing permissions to snaps than flatpak, in that classic confinement and special plugs require store approval. It has the same issue that most snaps provide access to the &quot;home&quot; plug for trivial access to much user data, but dotfiles are excluded so there is no trivial exploit through .bashrc, or reading of .config data, for example.
protoman3000over 4 years ago
If these things are true, author is talking about true, why are they not set to hardened by default?<p>Why is ptrace enabled by default, rather than disabled? Why is &#x2F;proc visible to any other process? Why aren’t the ASLR bits already set to 32?<p>This of course leads to the question, why is there even a way to change this and why don’t we live in a opt-out world? This reminds me about that whole Apple vs. Facebook discussion again
评论 #25591821 未加载
EE84M3iover 4 years ago
&gt;You have likely heard of regular protections such as Position Independent Executables, Stack Smashing Protector, immediate binding, read-only relocations and FORTIFY_SOURCE but this section will not go over those as they have already been widely adopted.<p>Is Debian PIE by default now? last time I checked, this was not included in their hardening patch to GCC, yet this was well over a year ago at this point.
评论 #25591860 未加载
anonunivgradover 4 years ago
This is meme security advice. Anti-systemd, anti-glibc, anti-openssl. This is security by internet fad.<p>As for the rest of the advice, it doesn&#x27;t explain any of the tradeoffs, making it worthless. The kernel devs and distribution maintainers are not idiots. If you can&#x27;t explain why it&#x27;s on, then you don&#x27;t understand it enough to turn it off.
egberts1over 4 years ago
This guide should be titled as “Compendium of Linux Hardening”.<p>It is not for the average system admin nor targeting a specific system usage model such as desktop workstation, embedded, or router&#x2F;gateway&#x2F;switch.<p>Given that, this guide is a very useful summary, which of course is only for the seasoned security developers and admin can use.<p>The rest of you can tread lightly.
mhoadover 4 years ago
Throwing this into the mix as another source on basically the same topic <a href="https:&#x2F;&#x2F;www.ncsc.gov.uk&#x2F;collection&#x2F;end-user-device-security&#x2F;platform-specific-guidance&#x2F;ubuntu-18-04-lts" rel="nofollow">https:&#x2F;&#x2F;www.ncsc.gov.uk&#x2F;collection&#x2F;end-user-device-security&#x2F;...</a>
slumdevover 4 years ago
Something that might help this article is to group the recommendations into a set of conceptual guidelines for hardening any system:<p>1. What ports are open?<p>1a. Can any of them be closed?<p>2. What services are running?<p>2a. Can any of them be stopped?<p>3. What permissions do those services have?<p>3a. Can any of them be reduced?<p>... and so on
synackover 4 years ago
Chrome OS does most of these things by default, at the cost of trusting Google.
评论 #25591332 未加载
wyuenhoover 4 years ago
Does anyone know how &quot;hardened&quot; various AWS&#x2F;Azure&#x2F;GCP linux distros are? Also, what about those popular base docker images? How &quot;hardened&quot; are they?
hendryover 4 years ago
Reminds me of CIS benchmarks and their hardened images <a href="https:&#x2F;&#x2F;youtu.be&#x2F;71ek_fm3TNs" rel="nofollow">https:&#x2F;&#x2F;youtu.be&#x2F;71ek_fm3TNs</a>
erikbyeover 4 years ago
If you want a battle tested hardening profile, use DISA’s STIG.
dartharvaover 4 years ago
As a newcomer, how many of these tips would you suggest for a Fedora&#x2F;Ubuntu&#x2F;&lt;whatever mainstream distro&gt; PC meant for everyday computing?
评论 #25592365 未加载
评论 #25599711 未加载
评论 #25590923 未加载
0dayzover 4 years ago
This sounds like an advert for alpine Linux.<p>That said, the take away I think for most users is: software side good (selinux, firewall, sandbox).<p>Kernel stuff tread with care.
whalesaladover 4 years ago
These are my absolute favorite resources. Succinct and to the point with lots of links to follow if you want to dive in for more.
captn3m0over 4 years ago
There’s still no usable userspace firewall on Linux. There’s OpenSnitch but it’s so far from being any good.
peter_retiefover 4 years ago
How do FreeBSD, OpenBSD, and NetBSD compare to Linux (Gentoo) for security?
Layke1123over 4 years ago
Is this really where we are on Hacker News? The brightest minds on the internet can&#x27;t even agree on systemd or other systems without coming to a sound conclusion? Now wonder tech is so fragmented.