Skip to content

Lab 02 — Linux Hardening

In the previous lab, you learned how to administer a Linux server.

Now you will move from:

Functional Linux Server

to:

Hardened Linux Server

Linux hardening is the process of reducing unnecessary attack surface while preserving the business functions the system is expected to provide.

Your objective is not:

Disable Everything

Your objective is:

Understand the Server
Identify Required Functions
Remove Unnecessary Exposure
Apply Security Controls
Validate Business Function
Document the Result

Lab: Linux Hardening
Level: Intermediate
Estimated Time: 120–180 minutes
Environment: Authorized disposable Linux VM
Primary Role: Linux Security Engineer
Secondary Roles: Cloud Security Engineer, System Administrator, SOC Analyst, DevSecOps Engineer

Your organization has deployed a new Linux server that will soon host an internal application.

Before the server can be approved for production use, the security team has asked you to perform a hardening review.

You must evaluate and improve:

System Baseline
Accounts
Administrative Privilege
Authentication
SSH
Filesystem Permissions
Temporary Directories
Installed Software
Running Services
Network Exposure
Host Firewall
Patching
Logging
Auditing
Time Synchronization
Security Controls

You must also ensure that your changes do not unnecessarily break the server.

By completing this lab, you should be able to:

  • Establish a Linux security baseline
  • Review local users and groups
  • Identify unnecessary or privileged accounts
  • Review administrative access
  • Evaluate password and account settings
  • Harden SSH safely
  • Identify unnecessary software
  • Review running services
  • Reduce network attack surface
  • Configure basic firewall restrictions
  • Review sensitive filesystem permissions
  • Identify world-writable locations
  • Review SUID and SGID files
  • Validate package and patch status
  • Review SELinux or AppArmor
  • Validate system logging
  • Review auditing capabilities
  • Verify time synchronization
  • Produce professional security findings
  • Create before-and-after hardening evidence
+----------------------------+
| Administrator |
| Security Engineer |
+-------------+--------------+
|
| SSH / Console
|
v
+----------------------------+
| Linux Lab Server |
| |
| Users & Groups |
| sudo |
| SSH |
| Services |
| Firewall |
| Packages |
| Filesystem |
| Logging |
| Security Controls |
+----------------------------+

Hardening can break systems if performed without understanding application requirements.

For every proposed change ask:

What Does This Control Protect?
What Depends on This Setting?
What Could Break?
How Will I Validate It?
How Will I Roll Back?

Use your own authorized disposable Linux VM.

Suitable examples include:

Ubuntu
Debian
Rocky Linux
AlmaLinux
Red Hat Enterprise Linux

Some commands and configuration locations vary between distributions.

Where appropriate, this lab provides both Debian-family and Red Hat-family concepts.

Take a VM snapshot if your virtualization platform supports it.

Record:

Snapshot Name:
Pre-Linux-Hardening

This gives you a safe recovery point.

Use this throughout the lab:

BASELINE
REVIEW
PRIORITIZE
CHANGE
VALIDATE
DOCUMENT

Do not begin changing settings immediately.

First understand the current system.

Run:

Terminal window
whoami

Then:

Terminal window
id

Record:

Current User:
UID:
Groups:
Administrative Access:

Run:

Terminal window
hostname
Terminal window
cat /etc/os-release
Terminal window
uname -r
Terminal window
uptime

Record:

Hostname:
Distribution:
Version:
Kernel:
Uptime:

Create:

Terminal window
mkdir -p ~/linux-hardening-lab

Enter it:

Terminal window
cd ~/linux-hardening-lab

Create folders:

Terminal window
mkdir baseline findings evidence

Create:

Terminal window
{
echo "Linux Hardening Baseline"
echo "========================"
echo "Date: $(date)"
echo "Hostname: $(hostname)"
echo "Kernel: $(uname -r)"
echo "Current User: $(whoami)"
} > baseline/system-info.txt

Review:

Terminal window
cat baseline/system-info.txt

A professional hardening exercise should preserve:

Before State

and:

After State

This helps demonstrate:

What Changed?
Why?
Did It Work?

Identity is one of the most important Linux security areas.

Start with:

Terminal window
getent passwd

Linux systems commonly contain:

Human Users
Administrative Users
Service Accounts
System Accounts

Do not assume every unfamiliar account is malicious.

Many are required by installed software.

Step 06 — Identify Interactive Shell Accounts

Section titled “Step 06 — Identify Interactive Shell Accounts”

Review:

Terminal window
getent passwd | grep -E '/bin/(bash|sh|zsh|fish)$'

The exact shells present depend on the system.

Ask:

Which Accounts Can Log In Interactively?

Run:

Terminal window
awk -F: '$3 == 0 {print $1 ":" $3 ":" $7}' /etc/passwd

Normally, highly privileged UID 0 accounts require strict review.

Document any unexpected results.

Ask:

Should Any Account
Besides the Approved
Administrative Identity
Have UID 0?

Accounts that do not require interactive login may use shells such as:

/usr/sbin/nologin

or:

/sbin/nologin

depending on the distribution.

The principle is:

No Interactive Requirement
No Interactive Shell

where operationally appropriate.

For every human account ask:

Who Owns It?
Why Does It Exist?
Is the User Still Active?
Which Groups Does It Belong To?
Does It Need Administrative Access?

Create documentation like:

Account Type Interactive Login Privileged Required
user1 Human Yes No Yes
service1 Service No No Yes
olduser Human Yes Unknown Review

Do not remove real accounts without authorization.

Run:

Terminal window
getent group

Look especially for groups that may grant elevated capabilities.

Examples depend on distribution, but may include administrative groups.

Step 10 — Review Your Administrative Group

Section titled “Step 10 — Review Your Administrative Group”

Run:

Terminal window
id

Then review the relevant administrative group using:

Terminal window
getent group <group-name>
Group Membership
Privilege

Therefore group membership is security-sensitive.

Administrative privilege should follow:

Least Privilege

Use:

Terminal window
sudo -l

to review the privileges of your current account.

Where authorized, inspect configuration carefully.

Main locations may include:

/etc/sudoers
/etc/sudoers.d/

Use safe inspection methods.

Do not edit /etc/sudoers directly with an ordinary text editor.

Use the approved validation workflow such as:

Terminal window
sudo visudo

when legitimate changes are required.

Ask:

Who Can Use sudo?
What Can They Run?
Can They Run Everything?
Is That Required?
Is Access Documented?
Finding:
Excessive Administrative Privilege
Observation:
A user has broad sudo access without
a documented administrative requirement.
Risk:
Compromise of the account could provide
full control of the Linux server.
Recommendation:
Restrict privileged access to the
minimum administrative functions
required for the user's role.

Part 05 — Review Password and Account Controls

Section titled “Part 05 — Review Password and Account Controls”

Password-related configuration differs by distribution and enterprise authentication model.

Review relevant account-aging information using:

Terminal window
chage -l <authorized-test-user>

Step 12 — Review Password Aging Concepts

Section titled “Step 12 — Review Password Aging Concepts”

Understand:

Minimum Password Age
Maximum Password Age
Expiration Warning
Account Expiration

Do not blindly apply arbitrary expiry settings.

Align with:

Organization Policy
Authentication Architecture
Regulatory Requirements

For training identities you control, understand the difference between:

Disable Interactive Access
Lock Password Authentication
Delete Account

Deletion is not always the correct security response.

During investigations, preserving the account may be necessary.

SSH is one of the most important Linux remote-access services.

First determine whether SSH is running.

Possible service names include:

ssh
sshd

Check the correct service for your distribution.

Example:

Terminal window
systemctl status sshd

or:

Terminal window
systemctl status ssh

The primary server configuration is commonly:

/etc/ssh/sshd_config

Additional configuration fragments may exist depending on the distribution.

Before changing anything, create an authorized backup:

Terminal window
sudo cp /etc/ssh/sshd_config /etc/ssh/sshd_config.lab-backup

Step 15 — Review Effective SSH Configuration

Section titled “Step 15 — Review Effective SSH Configuration”

Where supported:

Terminal window
sudo sshd -T

This is often more useful than reading only one configuration file because it can show effective settings.

Review:

Is Direct Root Login Required?
Which Authentication Methods Are Allowed?
Are Empty Passwords Allowed?
Which Users/Groups Can Connect?
Is SSH Exposed to the Correct Networks?
Are Logs Available?

A common security objective is:

Prevent Direct Remote Root Login

where administrative workflows permit it.

A common configuration consideration is:

PermitRootLogin

Do not change it blindly.

First ensure:

A Working Administrative Account Exists
sudo Works
Your Current Session Remains Open
Recovery Access Exists

Never close your current working SSH session immediately after changing remote-access configuration.

Use:

Existing Session
Apply Change
Validate Configuration
Reload Service
Open Second Session
Confirm Access
Only Then Close Original Session

Before reload or restart, use the platform’s supported syntax validation where available:

Terminal window
sudo sshd -t

No output normally indicates that no syntax problem was detected.

Always confirm behavior on your system.

Organizations may prefer:

SSH Keys
Central Identity
MFA-Integrated Access

over unmanaged password-only administrative access.

The correct configuration depends on your environment.

Do not disable a working authentication method until the replacement has been validated.

SSH exposure may be restricted using several layers:

Cloud Firewall
Network Firewall
Host Firewall
SSH User/Group Rules

Think:

Who Needs Access?
From Which Network?
Using Which Identity?

For authorized users, SSH public keys may be stored under locations such as:

~/.ssh/authorized_keys

Ask:

Who Owns This Key?
Is It Still Required?
When Was It Issued?
Is It Shared?
Can It Be Revoked?
Does the File Have Appropriate Permissions?

Never copy private SSH keys into:

Reports
Tickets
Chat
Source Repositories

More installed software generally means:

More Code
More Vulnerabilities
More Patches
More Attack Surface

Debian family:

Terminal window
dpkg -l

RPM family:

Terminal window
rpm -qa

Save package inventory if appropriate.

Example on RPM systems:

Terminal window
rpm -qa | sort > baseline/packages.txt

Example on Debian systems:

Terminal window
dpkg-query -W > baseline/packages.txt

Do not remove packages simply because you do not recognize them.

For each questionable package determine:

Purpose
Dependency
Application Owner
Support Requirement
Security Impact
Required Software
Keep + Maintain
Unnecessary Software
Review for Removal

Run:

Terminal window
systemctl --type=service --state=running

Create an inventory.

Ask for each service:

What Is It?
Why Is It Running?
Does the Application Need It?
Does It Listen on a Network Port?
Should It Start Automatically?

Where appropriate:

Terminal window
systemctl list-unit-files --type=service --state=enabled

Remember:

Running

and:

Enabled at Boot

are different conditions.

Service Running Enabled Network Exposed Required
SSH Yes Yes Yes Yes
Example Service Yes Yes Yes Review

If a harmless lab service is clearly unnecessary and you are authorized to modify it, use the appropriate service-management workflow.

Conceptually:

Confirm Not Required
Stop
Disable
Validate

Do not disable services merely to satisfy a checklist.

Finding:
Unnecessary Service Enabled
Observation:
A service without a confirmed business
requirement is running and configured
to start automatically.
Risk:
The service increases operating-system
attack surface and patch-management burden.
Recommendation:
Confirm service ownership and disable
or remove the service if it is not required.

Run:

Terminal window
sudo ss -lntup

Document:

Protocol
Address
Port
Process
Expected?
0.0.0.0:PORT

may indicate broader IPv4 listening exposure than:

127.0.0.1:PORT

depending on the application.

Similarly, review IPv6 bindings.

For every listening socket ask:

Should This Service
Listen on This Interface?

Part 12 — Map Ports to Business Requirements

Section titled “Part 12 — Map Ports to Business Requirements”

Create:

Port Service Bound Address Required Expected Source
22 SSH Example Yes Admin Network
443 Application Example Yes Approved Users
Unknown Unknown Example Review Unknown

This transforms:

Port Scan Data

into:

Security Context

Different Linux distributions use different firewall-management layers.

Common environments may include:

firewalld
nftables
ufw

Determine what your server uses before making changes.

If installed:

Terminal window
sudo firewall-cmd --state

Then:

Terminal window
sudo firewall-cmd --get-active-zones

Review active rules:

Terminal window
sudo firewall-cmd --list-all

If the system uses UFW:

Terminal window
sudo ufw status verbose

Your desired state is:

Required Traffic
Allowed
Unnecessary Traffic
Restricted

If you are connected through SSH:

DO NOT
Enable a restrictive firewall policy
before ensuring your approved SSH access
will remain allowed.

Otherwise you may lock yourself out.

After approved firewall changes validate:

SSH Still Works
Application Works
Required Port Accessible
Unnecessary Port Restricted

Use a second connection/session where practical.

Focus on sensitive locations such as:

/etc
/root
User SSH Directories
Application Configuration
Secrets Locations
Service Configuration
Terminal window
ls -l /etc/passwd

Use:

Terminal window
sudo ls -l /etc/shadow

Do not display or copy password-hash contents into your report.

Your goal is to review:

Owner
Group
Permissions

not secret material.

World-writable files can create security concerns depending on their purpose.

In your lab, perform a controlled review of the local filesystem.

One approach is:

Terminal window
sudo find / -xdev -type f -perm -0002 -print 2>/dev/null

Review results carefully.

Do not assume every result is automatically a vulnerability.

Step 27 — Review World-Writable Directories

Section titled “Step 27 — Review World-Writable Directories”

Conceptually, inspect directories writable by broad user populations.

Pay particular attention to:

Ownership
Sticky Bit
Business Purpose

Shared temporary directories often require specialized permission models.

Check:

Terminal window
ls -ld /tmp

On many systems you may see permissions conceptually similar to:

drwxrwxrwt

The final:

t

represents the sticky bit.

In a shared directory:

Many Users Can Create Files

but the sticky bit helps prevent users from deleting files owned by other users.

SUID can allow executables to operate with the effective identity of the file owner.

Inventory SUID files in your lab:

Terminal window
sudo find / -xdev -type f -perm -4000 -print 2>/dev/null

For each unexpected entry ask:

Which Package Owns It?
Why Is SUID Required?
Is It Part of the Approved Baseline?
Is It Supported?

Do not remove SUID from legitimate system binaries without understanding the impact.

Similarly:

Terminal window
sudo find / -xdev -type f -perm -2000 -print 2>/dev/null

Review unexpected entries.

Special Permission
Understand Purpose
Compare Baseline
Investigate Deviation

Part 20 — Review Home Directory Permissions

Section titled “Part 20 — Review Home Directory Permissions”

List:

Terminal window
ls -ld /home/*

Review whether home directories expose more information than required.

Consider:

Business Requirement
Shared Environment
Data Sensitivity
Application Compatibility

Part 21 — Review SSH Directory Permissions

Section titled “Part 21 — Review SSH Directory Permissions”

For your own account:

Terminal window
ls -ld ~/.ssh 2>/dev/null

and:

Terminal window
ls -l ~/.ssh 2>/dev/null

Do not expose private key contents.

Security-sensitive SSH files generally require tightly controlled ownership and permissions.

Run:

Terminal window
echo "$PATH"

Break the path into entries:

Terminal window
echo "$PATH" | tr ':' '\n'

Ask:

Does PATH Include
World-Writable Directories?
Does It Include "."?
Can Untrusted Users
Modify Earlier Directories?
Command Typed
PATH Search Order
First Matching Executable
Executed

Therefore search order matters.

Patch management is fundamental to hardening.

On Debian-family systems, approved update review may use:

Terminal window
sudo apt update

followed by an update assessment.

On Red Hat-family systems, appropriate DNF tools may be used to inspect available updates.

Do not automatically patch production systems simply because updates exist.

Use:

Identify
Assess
Test
Approve
Deploy
Validate

Step 28 — Document Pending Security Maintenance

Section titled “Step 28 — Document Pending Security Maintenance”

Record:

Packages Requiring Review:
Kernel Update Required?
Application Restart Required?
Reboot Required?
Change Window Needed?

Part 24 — Review Repository Configuration

Section titled “Part 24 — Review Repository Configuration”

Ensure package repositories are:

Expected
Approved
Trusted
Supported

Unknown package sources may create:

Software Supply-Chain Risk

On Red Hat-family systems:

Terminal window
getenforce

and:

Terminal window
sestatus

where available.

If SELinux is part of the approved platform design:

Use SELinux

rather than:

Disable SELinux
Because Something Failed

Possible states include:

Enforcing
Permissive
Disabled
Enforcing
Policy Applied
Permissive
Policy Violations Logged
Disabled
Policy Not Active

If an application fails:

Application Failure
Traditional Permissions
Logs
SELinux Context
Expected Policy
Correct Remediation

Do not simply turn off SELinux.

On distributions using AppArmor, determine whether profiles are active using the appropriate supported tools.

Conceptually review:

Profile Loaded?
Enforcing?
Complain Mode?
Application Covered?

SELinux and AppArmor provide:

Additional Policy Layer

beyond standard discretionary permissions.

Accurate system time is essential for:

Authentication
Logs
Incident Response
Distributed Applications
SIEM Correlation

Check:

Terminal window
timedatectl

Look for:

Timezone
System Clock
Synchronization State

Depending on your distribution, time synchronization may use services such as:

chronyd
systemd-timesyncd

Confirm the approved mechanism is healthy.

Run:

Terminal window
journalctl -n 50

Check whether:

System Events
Service Events
Authentication Events
Errors

are available.

Distribution-dependent locations may include:

/var/log/auth.log
/var/log/secure

or the system journal.

Use the appropriate source for your environment.

Logs may contain sensitive information.

Inspect:

Terminal window
ls -ld /var/log

Then review selected log-file ownership and permissions without copying sensitive content.

Hardening is incomplete if security events disappear too quickly.

Review:

Retention
Rotation
Disk Capacity
Central Forwarding
Linux Server
Local Logs
Central Collector
SIEM
SOC

Some Linux environments use:

auditd

for detailed auditing.

Determine whether it is present:

Terminal window
systemctl status auditd

where applicable.

Audit mechanisms can help record:

Administrative Actions
Sensitive File Access
System Calls
Account Changes
Security Events

Where authorized and supported:

Terminal window
sudo auditctl -l

Do not add large numbers of audit rules blindly.

Poorly designed auditing can:

Generate Noise
Consume Storage
Reduce Analyst Effectiveness

Persistence and maintenance can both use scheduled execution.

Review your user crontab:

Terminal window
crontab -l

Review relevant authorized system scheduling locations.

Ask:

Who Runs It?
What Executes?
Who Owns the Script?
Can an Untrusted User Modify It?
Is It Required?

Modern systems may use:

systemd timers

Review:

Terminal window
systemctl list-timers --all

This helps identify scheduled system activities.

Temporary directories may be used by many applications.

Security concerns include:

Predictable File Names
Weak Permissions
Untrusted Shared Locations
Sensitive Data Exposure

Do not delete temporary files blindly.

Applications may actively depend on them.

Run:

Terminal window
findmnt

Review mount options.

Security-sensitive mount options can include concepts such as:

nosuid
nodev
noexec

but these should not be applied blindly.

A filesystem holding executable applications may legitimately require execution.

Therefore use:

Filesystem Purpose
Security Requirement
Compatible Mount Options

Inspect:

Terminal window
cat /etc/fstab

Do not modify it without understanding boot impact.

Incorrect entries can prevent normal boot or mount required application storage incorrectly.

Linux exposes runtime kernel settings through mechanisms such as:

sysctl

Review selected settings with:

Terminal window
sysctl -a 2>/dev/null | less

Do not change kernel parameters randomly.

Networking Behavior
Address Forwarding
Redirect Handling
Memory Protections
Core Dumps

The correct hardening value depends on:

Server Role
Network Architecture
Application Requirement
Approved Security Baseline

Enterprise hardening commonly uses recognized guidance such as:

CIS Benchmarks
Vendor Security Guidance
Internal Security Baselines

Do not treat benchmarks as:

Blind Configuration Scripts

Use:

Control
Applicability
Risk
Business Impact
Implementation
Validation

Hardening also protects availability.

Ask:

Is the Server Backed Up?
What Is Backed Up?
Are Backups Protected?
Are They Encrypted?
Can They Be Restored?
Backup Exists

does not equal:

Recovery Works

until restoration has been tested.

A hardened system still needs a secure recovery procedure.

Document:

Console Access
Emergency Administrative Access
Recovery Credentials
Break-Glass Procedure
Backup Restore Procedure

These should be controlled and audited.

Part 41 — Perform Before-and-After Port Review

Section titled “Part 41 — Perform Before-and-After Port Review”

Before changes, save:

Terminal window
sudo ss -lntup > baseline/listening-ports.txt

After approved hardening, save:

Terminal window
sudo ss -lntup > evidence/listening-ports-after.txt

Compare:

Terminal window
diff baseline/listening-ports.txt evidence/listening-ports-after.txt

Not necessarily:

Zero Ports

but:

Only Required Ports

Capture enabled/running service baselines before and after approved modifications.

The goal is to demonstrate:

Reduced Unnecessary Services
No Broken Required Services

After any SSH change:

01 Validate Configuration
02 Reload Safely
03 Keep Existing Session
04 Open Second Session
05 Verify Authentication
06 Verify sudo
07 Confirm Logs

Never treat:

Service Reload Successful

as proof that administrators can still log in.

Test:

Required Administrative Access
Required Application Ports
Unexpected Ports
Local Services

The security objective is:

Business Function Works
+
Unnecessary Exposure Reduced

Hardening is not complete until business functionality is tested.

Check:

Application Running?
Required Service Healthy?
Required Port Available?
Storage Accessible?
DNS Working?
Authentication Working?
Logs Healthy?

Some changes may require:

Service Reload
Service Restart
Application Restart
System Reboot

Do not reboot automatically without understanding business impact.

A common mistake is creating a secure state that disappears after reboot.

Validate that appropriate settings are persistent.

Examples:

Firewall
Services
Mounts
System Configuration
Security Policy

Review the server using:

IDENTITY
Who can log in?
PRIVILEGE
Who can become administrator?
AUTHENTICATION
How is access verified?
SSH
Who can remotely connect?
FILES
Who can read or modify data?
SOFTWARE
What is installed?
SERVICES
What is running?
NETWORK
What is exposed?
FIREWALL
What is allowed?
MAC
Is SELinux/AppArmor active?
PATCHING
Is software maintained?
LOGGING
Can events be reconstructed?
AUDITING
Are important actions recorded?
TIME
Are timestamps reliable?
BACKUP
Can data be recovered?
Finding:
Unnecessary Network Exposure
Observation:
A network service is listening on an
interface accessible beyond its
documented business requirement.
Risk:
Additional network exposure increases
the remotely reachable attack surface.
Recommendation:
Restrict the service to the required
interface or network and enforce access
through approved host/network firewall
controls.
Finding:
Excessive Administrative Access
Observation:
Multiple accounts possess broad
administrative permissions without
documented operational requirements.
Risk:
Compromise or misuse of any privileged
account could result in full system
control.
Recommendation:
Apply least privilege, remove unnecessary
administrative memberships, and perform
periodic privileged-access reviews.
Finding:
Unnecessary Software Installed
Observation:
Software packages exist on the server
without an identified operational
requirement.
Risk:
Additional packages increase attack
surface and patch-management overhead.
Recommendation:
Confirm application dependencies and
remove unnecessary software through
the approved change process.
Finding:
Insufficient Security Logging
Observation:
Security-relevant events are not retained
or centrally collected for an appropriate
investigation period.
Risk:
Security incidents may be difficult to
detect, investigate, or reconstruct.
Recommendation:
Implement approved security-event
collection, retention, time
synchronization, and centralized logging.
Finding:
Mandatory Access Control Not Enforced
Observation:
The platform's approved mandatory
access-control mechanism is not enforcing
security policy.
Risk:
Compromised processes may operate with
fewer restrictions beyond traditional
Linux permissions.
Recommendation:
Determine the operational reason,
resolve compatibility issues, and restore
the approved enforcement state.

Not every issue has the same importance.

Use factors such as:

Exposure
Privilege
Exploitability
Business Criticality
Data Sensitivity
Existing Controls

Example prioritization:

Public Administrative Service
Higher Priority
Unused Local Package
Potentially Lower Priority

Context matters.

Your final report should contain:

Describe:

System Reviewed
Overall Security State
Highest-Risk Issues
Major Improvements
Hostname
Distribution
Server Role
Review Date
Authorized Scope

Include:

Accounts
Privileged Users
Services
Ports
Packages
Firewall State
Security Controls

For each approved change document:

Control
Previous State
New State
Reason
Validation

For each issue:

Finding
Observation
Risk
Evidence
Recommendation
Status

Document settings intentionally not changed because of:

Application Requirement
Business Requirement
Compatibility
Accepted Risk

Confirm:

SSH Access
Application Function
Networking
Firewall
Logging
Security Controls
Persistence
Control Before After Validation
Unnecessary service Running Disabled Service absent
SSH root access Review Hardened if applicable Second session tested
Firewall Review Required access only Connectivity tested
SELinux/AppArmor Review Approved state Policy validated
Logging Review Improved if needed Events visible

A professional hardening assessment may produce:

Exception

rather than:

Failure

Example:

Control:
Disable Service X
Decision:
Not Applied
Reason:
Service X is required by the application.
Compensating Controls:
Restricted firewall exposure
and centralized monitoring.
Owner:
Application Team

Security engineering is not:

Checklist Says Disable
Disable

It is:

Understand Risk
Understand Business
Design Appropriate Control

Think of hardening as stages.

Patch System
Remove Unused Accounts
Secure SSH
Enable Firewall
Approved Baseline
Central Logging
Privilege Review
Automated Updates Process
Configuration Monitoring
Configuration as Code
Continuous Compliance
Central IAM
Secrets Management
EDR
SIEM
Automated Drift Detection

When Linux runs in AWS, Azure, or Google Cloud, host hardening is only one layer.

Think:

Cloud IAM
Cloud Firewall
Linux Firewall
Linux Services
Application

All layers matter.

Even if:

Linux Firewall
Is Correct

a weak cloud IAM configuration can still create risk.

Similarly:

Cloud Security Group
Is Restricted

does not justify poor Linux permissions.

Part 60 — Linux Hardening and Containers

Section titled “Part 60 — Linux Hardening and Containers”

Container hosts also require Linux hardening.

Consider:

Host OS
Container Runtime
Users
Services
Firewall
Kernel
SELinux/AppArmor
Logging

A compromised host may affect multiple containers.

Part 61 — Linux Hardening and Kubernetes

Section titled “Part 61 — Linux Hardening and Kubernetes”

Kubernetes nodes still rely on Linux security.

Kubernetes
Container Runtime
Linux

Therefore Linux hardening supports:

Kubernetes Node Security
Runtime Security
Cluster Resilience

Hardening creates:

Known Good Baseline

which improves detection.

For example:

Expected Services = 8

Later:

Service 9 Appears

This creates a meaningful investigation lead.

Part 63 — Linux Hardening and Incident Response

Section titled “Part 63 — Linux Hardening and Incident Response”

Strong hardening improves incident response through:

Better Logs
Known Accounts
Reduced Services
Documented Configuration
Accurate Time
Strong Access Controls

Without a baseline it can be difficult to determine:

Normal

versus:

Suspicious

Part 64 — Hardening vs Vulnerability Management

Section titled “Part 64 — Hardening vs Vulnerability Management”

These are related but different.

Vulnerability Management
Known Software Weaknesses
Hardening
Secure Configuration

A fully patched server may still be insecure because of:

Weak SSH
Excessive sudo
Open Ports
Bad Permissions
Disabled Logging

Hardening reduces opportunities.

Monitoring detects activity.

Hardening
+
Monitoring
+
Incident Response
Defense in Depth

Without immediately applying changes, review your lab server and identify:

3 Identity Controls
3 Network Controls
3 Filesystem Controls
3 Logging Controls
3 Software Controls

For each classify:

Compliant
Needs Improvement
Not Applicable
Requires Business Review

Part 67 — Hardening Validation Challenge

Section titled “Part 67 — Hardening Validation Challenge”

After approved changes answer:

Can I Still Log In?
Does sudo Still Work?
Is the Application Healthy?
Are Required Ports Reachable?
Are Unnecessary Ports Restricted?
Are Logs Being Generated?
Is Security Policy Active?
Will Settings Survive Reboot?

Before every important modification document:

Configuration File:
Backup Location:
Original State:
Recovery Command:
Console Access Available:
Yes / No

Part 69 — Common Linux Hardening Mistakes

Section titled “Part 69 — Common Linux Hardening Mistakes”

Avoid:

Applying Checklists Blindly
Disabling SELinux
Disabling Firewall to Fix Problems
Removing Unknown Packages
Deleting System Accounts
Using chmod 777
Blocking Your Own SSH Access
Changing sudo Without Validation
Ignoring Application Requirements
Skipping Backups
Skipping Logs
Skipping Reboot Validation

Part 70 — Professional Hardening Workflow

Section titled “Part 70 — Professional Hardening Workflow”

Use this in real environments:

01 Obtain Authorization
02 Identify Server Role
03 Gather Baseline
04 Identify Required Services
05 Review Security Standard
06 Identify Gaps
07 Assess Business Impact
08 Create Change Plan
09 Create Rollback Plan
10 Test
11 Implement
12 Validate
13 Monitor
14 Document Exceptions
15 Produce Report

Submit:

01 System Baseline
02 User and Group Review
03 sudo Review
04 SSH Review
05 Service Inventory
06 Port Inventory
07 Firewall Review
08 Package Review
09 Permission Review
10 SUID/SGID Review
11 SELinux/AppArmor Review
12 Logging Review
13 Audit Review
14 Hardening Findings
15 Before-and-After Evidence
16 Final Hardening Report

A security benchmark recommends disabling a service, but the application team says it is required. What should you do?

Use:

Validate Requirement
Understand Exposure
Apply Compensating Controls
Document Exception
Monitor

Do not disable it blindly.

You change SSH settings and cannot reconnect. What went wrong?

Possible causes include:

Syntax Error
Authentication Disabled
Firewall Rule
User Restriction
Service Failure

This is why you:

Keep Existing Session
Validate Syntax
Test Second Connection

before closing access.

Why should you not disable SELinux simply because an application fails?

Because the failure may represent:

Incorrect Context
Incorrect Configuration
Policy Violation

Disabling SELinux removes an important security layer instead of correcting the root cause.

Why can a fully patched Linux system still be insecure?

Because security also depends on:

Identity
Privilege
Configuration
Services
Network Exposure
Permissions
Logging

Why capture a baseline before hardening?

Because it helps demonstrate:

Original State
Changes Made
Security Improvement
Rollback Information
  1. What is Linux hardening?
  2. Why is system hardening necessary?
  3. What is attack-surface reduction?
  4. Why should you establish a baseline before making changes?
  5. How do you identify interactive Linux users?
  6. Why should UID 0 accounts be reviewed?
  7. What is least privilege?
  8. How would you review sudo access?
  9. Why are service accounts different from human accounts?
  10. Why might a service account use nologin?
  11. What security risks exist with SSH?
  12. Why is direct root SSH login commonly restricted?
  13. Why should SSH configuration be syntax-validated?
  14. Why should you keep an existing SSH session during hardening?
  15. What is the purpose of a host firewall?
  16. How do you identify listening ports?
  17. Why should unnecessary services be disabled?
  18. Why should unnecessary packages be removed?
  19. What is a world-writable file?
  20. Why are world-writable directories security-sensitive?
  21. What is the sticky bit?
  22. What is SUID?
  23. Why should SUID files be reviewed?
  24. What is SGID?
  25. Why is PATH security-relevant?
  26. Why is patch management important?
  27. Why are third-party repositories a security concern?
  28. What is SELinux?
  29. What is the difference between enforcing and permissive?
  30. Why should SELinux not simply be disabled?
  31. What is AppArmor?
  32. Why is time synchronization security-relevant?
  33. Why is centralized logging useful?
  34. What does auditd provide?
  35. Why should scheduled tasks be reviewed?
  36. What are secure mount options?
  37. Why should hardening controls be tested for application compatibility?
  38. What is a security exception?
  39. What is configuration drift?
  40. How would you validate a Linux server after hardening?
  • Identified OS
  • Identified kernel
  • Recorded hostname
  • Recorded current identity
  • Captured package inventory
  • Captured service inventory
  • Captured port inventory
  • Reviewed users
  • Reviewed UID 0 accounts
  • Reviewed interactive shells
  • Reviewed service accounts
  • Reviewed groups
  • Reviewed privileged groups
  • Reviewed sudo access
  • Reviewed account policy
  • Reviewed account aging
  • Reviewed SSH access
  • Reviewed SSH authentication methods
  • Reviewed SSH keys
  • Protected administrative access
  • Reviewed installed packages
  • Identified unnecessary software
  • Reviewed update status
  • Reviewed repository trust
  • Reviewed running services
  • Reviewed enabled services
  • Mapped services to business requirements
  • Disabled only approved unnecessary services
  • Reviewed interfaces
  • Reviewed listening ports
  • Reviewed bound addresses
  • Reviewed host firewall
  • Validated required connectivity
  • Reduced unnecessary exposure
  • Reviewed sensitive file permissions
  • Reviewed world-writable files
  • Reviewed world-writable directories
  • Reviewed /tmp
  • Reviewed SUID files
  • Reviewed SGID files
  • Reviewed home-directory permissions
  • Reviewed SSH-directory permissions
  • Reviewed SELinux/AppArmor
  • Reviewed policy state
  • Reviewed time synchronization
  • Reviewed system logging
  • Reviewed authentication logging
  • Reviewed auditing
  • Reviewed scheduled tasks
  • Reviewed backup status
  • Reviewed recovery access
  • Documented rollback approach
  • Validated required services
  • Validated persistence
  • Recorded before state
  • Recorded after state
  • Documented changes
  • Documented exceptions
  • Created findings
  • Created final report

When hardening Linux, think:

KNOW THE SYSTEM
KNOW THE BUSINESS FUNCTION
KNOW WHO NEEDS ACCESS
REMOVE WHAT IS NOT REQUIRED
RESTRICT WHAT REMAINS
PATCH WHAT MUST RUN
LOG IMPORTANT ACTIVITY
VALIDATE BUSINESS FUNCTION
MONITOR FOR DRIFT

The goal is not:

Maximum Restriction

The goal is:

Minimum Necessary Exposure
+
Maximum Practical Security
+
Required Business Function

You have now worked through a structured Linux hardening workflow covering:

System Baseline
User Security
Privilege Management
SSH Security
Package Security
Service Reduction
Filesystem Security
Network Exposure
Firewall Controls
SELinux/AppArmor
Logging
Auditing
Time Synchronization
Recovery
Validation

You have moved from:

Linux Administrator

toward:

Linux Security Administrator

Most importantly, you learned that professional hardening follows:

BASELINE
UNDERSTAND
HARDEN
VALIDATE
DOCUMENT
MONITOR

➡️ Lab 03 — Linux IAM

In the next lab, you will focus specifically on Linux identity and access management.

You will work through:

Users
Groups
UID/GID
Password Controls
Account Lifecycle
File Ownership
Permissions
ACLs
sudo
Service Accounts
SSH Keys
Privileged Access Review

Your Linux lab journey continues:

Lab 01 — Linux Administration
Lab 02 — Linux Hardening
Lab 03 — Linux IAM
Lab 04 — Linux Networking
Lab 05 — Linux Security
Runbook 01 — Linux Incident Investigation
Runbook 02 — Linux Security Assessment
Runbook 03 — Linux Server Hardening