Automating server security with Ansible

Summary

At the Chemnitz Linux Days 2021, Dr. Benjamin Aleritsch showed how server security can be automated with Ansible. It is based on two established frameworks: SCAP standardises the automatic discovery of vulnerabilities and checking against security guidelines, while STIG provides specific requirements for hardening systems. The English-language talk gave an introduction to this process.

Why automate security?

A server can be hardened by hand: switch off unnecessary services, set secure SSH options, define password rules, enable logging. With dozens or hundreds of systems this is error-prone, and over time the systems drift apart. Automation ensures that every machine has the same verified state and that deviations stand out.

Ansible describes the desired state in readable text files called playbooks and enforces it on the target systems via SSH without an additional agent. Combined with SCAP checks, for example with OpenSCAP, this creates a cycle: check, harden, check again.

What SCAP and STIG are

SCAP, the Security Content Automation Protocol, is a collection of standards from the US NIST that make it possible to describe security checks in machine-readable form. STIGs, Security Technical Implementation Guides, are hardening requirements from the US defence agency DISA. They also serve as useful checklists outside the USA, similar to the Center for Internet Security benchmarks or, in Germany, the BSI’s IT-Grundschutz.

Ideas

  • Ansible applies a described security state uniformly to many servers.
  • SCAP makes security checks machine-readable and repeatable.
  • Checking, hardening and checking again form a cycle.

Insights

  • Manual hardening does not scale and leads to diverging systems over time.
  • Established frameworks save you from inventing security requirements yourself.

Facts

  • SCAP is a collection of standards from NIST.
  • STIGs are published by the US agency DISA.
  • The talk was listed in the programme as “Server Security Automation with Ansible”.

References

Remarks

  • Ready-made Ansible roles for hardening exist for Debian, Ubuntu and RHEL, for example from the ansible-lockdown project or from OpenSCAP profiles.

Recommendations

  • Start with an OpenSCAP report and then harden the most important deviations specifically.
  • Test hardening rules on a copy, because overly strict requirements can block services or remote access.

Open the programme item

Search the Web Archive

Found a mistake or have something to add? Get in touch.