Automated Security Hardening for Ubuntu Server

Today, I am looking at a set of security scripts, which harden Ubuntu Server (20.04 or 22.04). Hardening is the process to change the system configuration in order to meet the basic set of compliance standards. In this example we will receive our compliance information from lynis, CIS and the DISA STIG. There are several things to discuss before jumping into the video.

WARNING: Never try a new automation script on production servers without first testing it in a controlled lab on test equipment! – you have been warned

First, how do we know what we need to change on our systems in order to bring it into compliance with various agency and regulatory standards. The first is the tool set provided by:

Second, Once we have applied the changes to our system, how do we know we have met the standards we are trying to comply with?

Security Content Automation Protocol (SCAP) is a method for using specific standards to help organizations automate vulnerability management and policy compliance evaluation. SCAP comprises numerous open security standards, as well as applications which use these standards to check systems for vulnerabilities and misconfigurations.

One of the compliance files is called a STIG or A Security Technical Implementation Guide is a configuration standard consisting of cybersecurity requirements for a specific product. These are usually crafted for a specific operating system and version such as Ubuntu 20.04, RedHat 8, etc.

One other method of security validation I did not show is CIS Ubuntu Security Benchmark and you can find more information here:

00:00 – Intro
00:28 – Preparations
01:31 – Setup the Server
06:40 – Change ubuntu.cfg
08:56 – running the script
09:38 – validating the changes
11:17 – Running a few tests (768)
14:46 – OpenSCAP Run
16:19 – SCAP Analysis
21:17 – Final Thoughts
22:12 – Outro

Support me on Patreon:
Follow me:
Twitter @djware55

“Tech Live” Kevin MacLeod (
Licensed under Creative Commons: By Attribution 4.0 License

“Militaire Electronic” Kevin MacLeod (
Licensed under Creative Commons: By Attribution 4.0 License

Werq by Kevin MacLeod

Industrial Cinematic by Kevin MacLeod

Music Used in this video
“NonStop” Kevin MacLeod (
Licensed under Creative Commons: By Attribution 3.0 License

#Infosec #SCAP #STIG


Avatar of DJ Ware

By DJ Ware

10 thoughts on “Automated Security Hardening for Ubuntu Server”
  1. A score of 92 with Lynis is pretty good (to my limited knowledge that is).
    I'm not a system administrator or security expert by any stretch of the imagination. But still quite interesting to see these kind of video's about security.
    Thank you for researching / testing and explaining these kind of security scripts / tools.

  2. Give your thoughts on systemd? Maybe you have mentioned it but I have not come across it. I don't find it to be as evil as many claim but I get where they're coming from .

  3. Of course this automation isnt meant for development machines, possibly not test machines (integration test). Possibly could be used on a system test machine and of course a production server.

Leave a Reply

Your email address will not be published.

Captcha loading...