explaingit

trimstray/the-practical-linux-hardening-guide

10,512Audience · ops devopsComplexity · 3/5Setup · hard

TLDR

A practical guide for hardening Linux servers by reducing their attack surface, following CIS benchmarks and DISA STIG standards, with automated compliance scanning via OpenSCAP.

Mindmap

mindmap
  root((repo))
    What it Does
      Reduces attack surface
      Follows CIS and STIG
      Automated compliance scan
    Topics Covered
      User account controls
      Firewall configuration
      Software maintenance
    Compliance Frameworks
      NIST 800-53
      PCI-DSS
      CIS benchmarks
    Tooling
      OpenSCAP scanner
      RHEL and CentOS
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Use OpenSCAP to automatically scan a RHEL 7 or CentOS 7 server and get a report of which settings comply with CIS or STIG policies.

USE CASE 2

Apply the firewall and user account hardening steps to reduce the attack surface of a freshly provisioned Linux server.

USE CASE 3

Use the guide as a reference when working toward PCI-DSS or NIST 800-53 compliance in a regulated environment.

USE CASE 4

Adapt the OpenSCAP scan profiles to audit any Linux distribution's configuration against named security benchmarks.

Tech stack

LinuxOpenSCAPRHELCentOS

Getting it running

Difficulty · hard Time to first run · 1h+

Requires a RHEL 7 or CentOS 7 system and familiarity with Linux administration, applying changes to a production server without testing can break services.

In plain English

This is a guide for making Linux servers more secure, written as a practical reference rather than an official standard. Hardening refers to the process of reducing a system's attack surface by changing default settings, disabling unnecessary services, tightening access controls, and configuring the system to follow recognized security benchmarks. Out of the box, a Linux server is set up for convenience and broad compatibility, not for security, so there is real work involved in tightening it down. The guide is structured around industry-recognized compliance frameworks rather than informal advice. The main references are the Center for Internet Security benchmarks and the DISA STIG specifications, both of which are widely used in government and enterprise environments. Following these standards is shown to address 80 to 95 percent of known vulnerabilities in a typical configuration. The guide also references NIST 800-53 and PCI-DSS for readers working in regulated industries. For actually applying the checks, the guide uses OpenSCAP, a tool that can automatically scan a system and report on which settings comply with a chosen policy and which do not. Several OpenSCAP configurations are referenced, tuned for Red Hat Enterprise Linux 7 and CentOS 7, which are the distributions this guide is tested on. Other distributions can use most of the same guidance even if the exact commands differ. Each section follows a consistent structure: a rationale explaining why a change matters, a solution aligned with a named policy, comments with practical context, and links to further reading. The guide covers areas like user account management, firewall configuration, software maintenance, and general principles such as avoiding running services as root and limiting installed software to what is actually needed.

Copy-paste prompts

Prompt 1
I have a fresh CentOS 7 server. Walk me through the most important steps from the practical-linux-hardening-guide to harden it against the CIS benchmark, starting with user account controls.
Prompt 2
Using the practical-linux-hardening-guide as a reference, write a shell script that applies the firewall hardening rules it recommends for RHEL 7.
Prompt 3
I need to run an OpenSCAP scan on my Linux server using the CIS profile. Give me the exact commands to install OpenSCAP, download the relevant policy, and produce a compliance report.
Prompt 4
Summarize the rationale behind the 'avoid running services as root' principle from the practical-linux-hardening-guide and list the specific steps it recommends to enforce it.
Prompt 5
My team needs to achieve 80% compliance with DISA STIG on CentOS 7. Based on the practical-linux-hardening-guide, which sections should we prioritize first?
Open on GitHub → Explain another repo

← trimstray on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.