Runbook 03 β Linux Server Hardening
A security assessment identifies:
What Is Weak?Server hardening answers:
How Do We Reduce the Risk?Linux hardening is not simply:
Disable Everything
Block Everything
Remove EverythingA production server still needs to perform its business function.
The objective is to create:
Secure+Stable+Supportable+Observable+RecoverableLinux infrastructure.
Runbook Information
Section titled βRunbook InformationβRunbook: Linux Server Hardening
Level: Intermediate β Advanced
Primary Role: Linux Security Engineer
Supporting Roles: System Administrator, Cloud Security Engineer, DevSecOps Engineer, Security Consultant, Platform Engineer
Environment: Authorized Linux servers
Objective: Reduce Linux attack surface while preserving required business functionality.
Mission Scenario
Section titled βMission ScenarioβA Linux server has completed its security assessment.
The assessment identified several weaknesses:
Pending Security Updates
Dormant User Accounts
Excessive sudo Access
Broad SSH Exposure
Unnecessary Services
Weak File Permissions
Overly Permissive Firewall Rules
Incomplete Security Logging
Inconsistent HardeningThe server is scheduled for production deployment.
You have been assigned to create and execute the approved hardening plan.
Your job is to move the system from:
Functional Linux Serverto:
Hardened Production Linux Serverwithout unnecessarily disrupting the application.
Hardening Philosophy
Section titled βHardening PhilosophyβUse:
UNDERSTAND βBASELINE βBACK UP βHARDEN βTEST βVALIDATE βMONITOR βDOCUMENTGolden Rule
Section titled βGolden RuleβNever harden production systems blindly.
Do not:
Copy Random Internet Commands
Apply Every Benchmark Setting
Disable Services Without Validation
Change SSH Without Recovery Access
Modify Firewall Rules Without Testing
Disable SELinux to Fix Problems
Delete Accounts Without Ownership ReviewInstead:
Requirement βRisk βApproved Change βControlled Implementation βValidation βRollback if RequiredHardening Mental Model
Section titled βHardening Mental ModelβThink in layers:
APPLICATION β DATA β PROCESS β SERVICE β FILESYSTEM β IDENTITY β PRIVILEGE β NETWORK β LINUX KERNEL β INFRASTRUCTURESecurity should exist at every layer.
Phase 01 β Confirm Authorization
Section titled βPhase 01 β Confirm AuthorizationβBefore making changes confirm:
Server Is In Scope
Hardening Is Approved
Change Window Is Approved
Application Owner Is Available
Rollback Plan Exists
Backup Exists
Recovery Access Exists
Monitoring Team Is InformedChange Record
Section titled βChange RecordβDocument:
Change ID:
Server:
Business Owner:
Technical Owner:
Change Window:
Hardening Engineer:
Approved By:
Rollback Owner:
Validation Owner:Phase 02 β Understand the Server Role
Section titled βPhase 02 β Understand the Server RoleβDo not harden before understanding:
What Does the Server Do?
Which Applications Run?
Which Ports Are Required?
Which Users Need Access?
Which Services Are Required?
Which External Systems Are Required?
Which Data Is Processed?
What Availability Is Required?Example
Section titled βExampleβA web server may legitimately require:
TCP 443A database server may require:
Database Portbut only from:
Approved Application ServersHardening should reduce unnecessary access without breaking required access.
Phase 03 β Establish the Approved Baseline
Section titled βPhase 03 β Establish the Approved BaselineβPossible references include:
Organizational Linux Standard
Vendor Hardening Guidance
CIS Benchmark
Cloud Security Standard
Application Requirements
Regulatory RequirementsImportant
Section titled βImportantβA benchmark is:
Security Guidancenot:
Blind Configuration ScriptEvaluate every control against:
Linux Distribution
Version
Server Role
Application Compatibility
Operational Requirements
Threat ModelPhase 04 β Capture the Pre-Hardening Baseline
Section titled βPhase 04 β Capture the Pre-Hardening BaselineβBefore changing anything, capture the current state.
Useful information includes:
hostnamectlcat /etc/os-releaseuname -ruptimeip -brief addressip routesudo ss -lntupsystemctl --type=service --state=runningsystemctl list-unit-files --type=service --state=enabledCapture Security State
Section titled βCapture Security StateβAlso record:
Users
Groups
sudo Access
SSH Configuration
Firewall
SELinux/AppArmor
Installed Packages
Logging
Audit Configuration
Scheduled TasksWhy Baseline First?
Section titled βWhy Baseline First?βYou need to know:
BEFOREso that you can prove:
AFTERPhase 05 β Prepare Rollback
Section titled βPhase 05 β Prepare RollbackβBefore high-impact changes, determine:
How Will We Recover?Possible mechanisms include:
VM Snapshot
Cloud Snapshot
Configuration Backup
Infrastructure as Code
Configuration Management
System Backup
Known-Good ImageImportant
Section titled βImportantβA snapshot is not always a complete backup strategy.
Understand:
Application Consistency
Database State
Encryption
Dependencies
Recovery ProcedurePhase 06 β Preserve Configuration
Section titled βPhase 06 β Preserve ConfigurationβBefore modifying important files, follow your organizationβs configuration-management procedure.
Important configuration may include:
SSH
sudo
Firewall
Network
Authentication
Application Services
SELinux/AppArmor
Logging
AuditChange Principle
Section titled βChange PrincipleβEvery important change should have:
Original State
New State
Reason
Owner
Validation
RollbackPhase 07 β Patch the Operating System
Section titled βPhase 07 β Patch the Operating SystemβPatching is one of the highest-value hardening activities.
Use the supported package-management process for the distribution.
Debian-family environments commonly use:
APTRHEL-family environments commonly use:
DNF / RPMPatch Workflow
Section titled βPatch WorkflowβInventory βIdentify Updates βReview Security Relevance βTest βApprove βDeploy βReboot if Required βValidateDo Not Blindly Patch Production
Section titled βDo Not Blindly Patch ProductionβConsider:
Application Compatibility
Kernel Changes
Library Dependencies
Maintenance Window
Cluster Redundancy
RollbackPhase 08 β Review Repository Trust
Section titled βPhase 08 β Review Repository TrustβSoftware should come from approved sources.
Review:
Configured Repositories
Repository Ownership
Signing
Third-Party Sources
Unsupported RepositoriesSupply Chain Model
Section titled βSupply Chain ModelβTrusted Source βVerified Package βApproved Version βControlled DeploymentFinding to Hardening Action
Section titled βFinding to Hardening ActionβFinding:Unapproved Repository
Hardening:Remove or disable unapproved sourceafter validating application dependency.Phase 09 β Remove Unnecessary Software
Section titled βPhase 09 β Remove Unnecessary SoftwareβEvery unnecessary package can add:
Code
Dependencies
Potential Vulnerabilities
Maintenance BurdenBut do not remove packages simply because you do not recognize them.
Use:
Package βPurpose βDependency βBusiness Requirement βDecisionPhase 10 β Review User Accounts
Section titled βPhase 10 β Review User AccountsβInventory:
getent passwdClassify accounts:
Human
Administrator
Service
SystemAccount Hardening Questions
Section titled βAccount Hardening QuestionsβIs the Account Required?
Who Owns It?
Can It Log In?
Should It Log In?
What Groups Does It Belong To?
Does It Have Administrative Access?Phase 11 β Remove Dormant Access
Section titled βPhase 11 β Remove Dormant AccessβFor accounts no longer required:
Validate Owner βDisable Access βPreserve Required Data βRemove According to PolicyNever delete accounts simply because they appear inactive.
Validate:
Application Dependencies
File Ownership
Scheduled Jobs
Service Ownershipfirst.
Phase 12 β Review UID 0
Section titled βPhase 12 β Review UID 0βRun:
awk -F: '$3 == 0 {print $1 ":" $3 ":" $7}' /etc/passwdUnexpected UID 0 identities should be investigated and remediated.
Desired Model
Section titled βDesired ModelβIndividual Administrator βsudo βControlled Root Privilegeinstead of multiple root-equivalent accounts.
Phase 13 β Harden Service Accounts
Section titled βPhase 13 β Harden Service AccountsβService accounts should normally receive only the capabilities their workload requires.
Review:
Interactive Shell
Password Authentication
Home Directory
Group Membership
sudo
File Ownership
Network AccessService Account Model
Section titled βService Account ModelβApplication βDedicated Identity βRequired Files βRequired Process βMinimum PrivilegePhase 14 β Review Password Controls
Section titled βPhase 14 β Review Password ControlsβWhere password authentication is used, align controls with organizational policy.
Consider:
Password Quality
Password Reuse
Account Locking
Password Aging
Compromised Credential DetectionDo not apply arbitrary password expiration values simply because a generic benchmark suggests them.
Phase 15 β Review PAM
Section titled βPhase 15 β Review PAMβPluggable Authentication Modules can influence:
Authentication
Password Quality
Account Restrictions
Session ControlsChanges to PAM can lock users out.
Therefore:
Understand βTest βMaintain Recovery Access βImplement βValidatePhase 16 β Harden Privileged Access
Section titled βPhase 16 β Harden Privileged AccessβReview:
sudo -lReview approved sudo configuration.
Use:
visudofor safe sudo configuration editing where appropriate.
ALL=(ALL) ALLfor every administrator unless genuinely required.
Also review overly broad:
NOPASSWD
Wildcards
Shell Execution
Editable Scripts
Unrestricted Administrative GroupsPrivilege Principle
Section titled βPrivilege PrincipleβUser βRole βRequired Administrative Task βMinimum PrivilegePhase 17 β Separate Administrative Identities
Section titled βPhase 17 β Separate Administrative IdentitiesβWhere organizational architecture requires it, administrators may use separate identities for:
Normal Workand:
Privileged AdministrationThis reduces exposure of privileged credentials.
Phase 18 β Harden SSH
Section titled βPhase 18 β Harden SSHβSSH is often one of the most important Linux administrative controls.
Start by reviewing the effective configuration where supported:
sudo sshd -TDo not change SSH before confirming:
Console Access
Second Administrative Session
Recovery MethodPhase 19 β Validate SSH Configuration Before Reload
Section titled βPhase 19 β Validate SSH Configuration Before ReloadβAfter approved changes:
sudo sshd -tOnly proceed when configuration validation succeeds.
SSH Hardening Areas
Section titled βSSH Hardening AreasβReview:
Root Login
Password Authentication
Public-Key Authentication
Empty Passwords
Allowed Users / Groups
Idle Sessions
Logging
Cryptographic Configuration
Network ExposureExact settings should follow the supported SSH version and organizational standard.
Phase 20 β Root SSH Access
Section titled βPhase 20 β Root SSH AccessβWhere direct root SSH is not required, prefer:
Administrator βIndividual Account βsudoThis improves:
Accountability
Auditability
Access ControlPhase 21 β SSH Authentication
Section titled βPhase 21 β SSH AuthenticationβWhere architecture supports it:
Managed Public-Key Authenticationmay be preferable to reusable passwords.
But keys require lifecycle management:
Issue
Protect
Inventory
Rotate
RevokePhase 22 β Protect SSH Key Files
Section titled βPhase 22 β Protect SSH Key FilesβCommon user-side permission expectations include:
~/.sshrestricted to the user and:
authorized_keysprotected from unauthorized modification.
For example, where appropriate:
chmod 700 ~/.sshchmod 600 ~/.ssh/authorized_keysValidate ownership as well.
Phase 23 β Restrict SSH Users
Section titled βPhase 23 β Restrict SSH UsersβWhere required, restrict remote administration to approved identities or groups.
The architecture should resemble:
Approved Admin Group βSSH βLinux Serverrather than every local identity automatically receiving remote access.
Phase 24 β Restrict SSH Network Exposure
Section titled βPhase 24 β Restrict SSH Network ExposureβHost configuration is only one layer.
Use:
Management Network βNetwork Firewall βHost Firewall βSSHwhere architecture permits.
Phase 25 β Filesystem Hardening
Section titled βPhase 25 β Filesystem HardeningβReview:
Ownership
Permissions
ACLs
Special Permissions
Mount Options
Sensitive DataFilesystem Principle
Section titled βFilesystem PrincipleβUser βOnly Required Files βOnly Required PermissionsPhase 26 β Review Sensitive System Files
Section titled βPhase 26 β Review Sensitive System FilesβImportant examples include:
/etc/passwd
/etc/shadow
/etc/group
sudo Configuration
SSH Configuration
Private Keys
Application SecretsAssess metadata without unnecessarily exposing contents.
Phase 27 β Remove Excessive Permissions
Section titled βPhase 27 β Remove Excessive PermissionsβAvoid:
chmod 777as a generic troubleshooting technique.
Instead determine:
Which Identity Needs Access?
Read?
Write?
Execute?Then grant only those permissions.
Phase 28 β Review World-Writable Files
Section titled βPhase 28 β Review World-Writable FilesβIn an authorized environment:
sudo find / -xdev -type f -perm -0002 -print 2>/dev/nullFor each result:
Purpose
Owner
Business Need
Security ImpactDo not automatically change every result.
Phase 29 β Review Shared Directories
Section titled βPhase 29 β Review Shared DirectoriesβFor locations such as:
/tmpreview:
Ownership
Permissions
Sticky Bit
Mount Configuration
UsagePhase 30 β Review SUID
Section titled βPhase 30 β Review SUIDβInventory:
sudo find / -xdev -type f -perm -4000 -print 2>/dev/nullFor every result ask:
Expected?
Required?
Which Package?
Approved Baseline?
Known Security Risk?Do not blindly remove SUID permissions from operating-system files.
Phase 31 β Review SGID
Section titled βPhase 31 β Review SGIDβInventory:
sudo find / -xdev -type f -perm -2000 -print 2>/dev/nullApply the same validation process.
Phase 32 β Review ACLs
Section titled βPhase 32 β Review ACLsβACLs can grant access beyond traditional:
Owner
Group
OtherEnsure ACLs do not create unexpected access to sensitive data.
Phase 33 β Harden Home Directories
Section titled βPhase 33 β Harden Home DirectoriesβReview:
ls -ld /home/*Ensure permissions align with:
Privacy Requirements
Application Requirements
Collaboration RequirementsPhase 34 β Review umask
Section titled βPhase 34 β Review umaskβumask influences default permissions for newly created files and directories.
Review the organizational standard rather than applying arbitrary values globally.
Consider:
Users
Administrators
Service Accounts
Applicationsbecause different workloads may have different requirements.
Phase 35 β Review Mount Security
Section titled βPhase 35 β Review Mount SecurityβDepending on workload, mount options may include controls such as:
nodev
nosuid
noexecThese are not universally appropriate.
For example:
noexecmay break applications that legitimately execute from the filesystem.
Use:
Threat Model+Workload Requirementbefore applying.
Phase 36 β Review /etc/fstab
Section titled βPhase 36 β Review /etc/fstabβIncorrect changes can prevent a system from booting.
Before modifying:
Back Up Configuration
Validate Syntax
Confirm Recovery Access
Test Mount BehaviorPhase 37 β Reduce Service Attack Surface
Section titled βPhase 37 β Reduce Service Attack SurfaceβInventory:
systemctl --type=service --state=runningand:
systemctl list-unit-files --type=service --state=enabledFor each service:
Required?
Owner?
Network Exposure?
Privilege?
Startup Required?Phase 38 β Disable Unnecessary Services
Section titled βPhase 38 β Disable Unnecessary ServicesβFor approved unnecessary services:
Validate Dependency βStop βDisable βValidate Application βConfirm Port ClosedDo not disable unfamiliar services without understanding them.
Phase 39 β Verify Listener Reduction
Section titled βPhase 39 β Verify Listener ReductionβBefore:
sudo ss -lntupAfter:
sudo ss -lntupCompare:
BEFORE βHARDEN βAFTERThis proves attack-surface reduction.
Phase 40 β Network Hardening
Section titled βPhase 40 β Network HardeningβReview:
Interfaces
Routes
Listening Ports
Inbound Access
Outbound Access
IPv4
IPv6Network Principle
Section titled βNetwork PrincipleβOnly Required CommunicationShould Be AllowedPhase 41 β Review IP Forwarding
Section titled βPhase 41 β Review IP ForwardingβA standard application server usually does not need to operate as a router.
Review:
sysctl net.ipv4.ip_forwardDo not disable forwarding if the system legitimately functions as:
Router
Gateway
VPN Server
Container Networking Hostwithout understanding the impact.
Phase 42 β Review Network Kernel Parameters
Section titled βPhase 42 β Review Network Kernel ParametersβDepending on server role and approved baseline, review settings related to:
Forwarding
Redirects
Source Routing
Reverse Path Validation
Network LoggingDo not paste generic sysctl hardening configurations across every server.
Phase 43 β Persist Approved sysctl Settings
Section titled βPhase 43 β Persist Approved sysctl SettingsβPersistent custom settings are commonly managed under:
/etc/sysctl.d/Use organization-controlled configuration files and configuration management where possible.
Phase 44 β Harden the Host Firewall
Section titled βPhase 44 β Harden the Host FirewallβIdentify the active firewall technology:
firewalld
nftables
ufwFirewall Design
Section titled βFirewall DesignβStart from:
What Must Be Reachable?not:
What Can We Block?Phase 45 β firewalld Review
Section titled βPhase 45 β firewalld ReviewβOn applicable systems:
sudo firewall-cmd --get-active-zonesThen:
sudo firewall-cmd --list-allReview:
Zone
Interfaces
Services
Ports
Sources
ForwardingPhase 46 β UFW Review
Section titled βPhase 46 β UFW ReviewβOn applicable systems:
sudo ufw status verboseReview allowed services and source ranges.
Phase 47 β nftables Review
Section titled βPhase 47 β nftables ReviewβWhere used:
sudo nft list rulesetReview the active ruleset against the approved network design.
Phase 48 β Firewall Hardening Principle
Section titled βPhase 48 β Firewall Hardening PrincipleβPrefer:
DENY UNNECESSARY +ALLOW REQUIREDFor example:
Internet βHTTPS 443 βWeb Serverwhile administration follows:
Management Network βSSH 22 βWeb ServerPhase 49 β Protect Yourself from Lockout
Section titled βPhase 49 β Protect Yourself from LockoutβBefore tightening remote firewall access:
Confirm Current Source IP
Allow Required Management Path
Maintain Secondary Session
Maintain Console Access
Apply Change
Test New Session
Only Then Close Recovery SessionPhase 50 β Review Outbound Access
Section titled βPhase 50 β Review Outbound AccessβInbound controls are not enough.
Ask:
Does the Server NeedUnrestricted Internet Access?Required outbound destinations may include:
Package Repositories
DNS
NTP
Monitoring
Backup
Application APIsConsider restricting unnecessary egress where architecture supports it.
Phase 51 β SELinux Hardening
Section titled βPhase 51 β SELinux HardeningβOn SELinux systems:
getenforceand:
sestatusA security-focused production baseline will often expect:
Enforcingwhere supported and required.
Never Use
Section titled βNever UseβDisable SELinuxas the default troubleshooting strategy.
Correct SELinux Troubleshooting
Section titled βCorrect SELinux TroubleshootingβApplication Fails βCheck Normal Permissions βCheck Logs βCheck SELinux Denial βCheck Context βCheck Boolean βCorrect ConfigurationPhase 52 β Review SELinux Contexts
Section titled βPhase 52 β Review SELinux ContextsβUse:
ls -Z <path>where appropriate.
Incorrect labels should normally be corrected using supported policy-aware mechanisms rather than arbitrary permanent changes.
Phase 53 β SELinux Booleans
Section titled βPhase 53 β SELinux BooleansβSELinux booleans can enable specific policy capabilities.
The process should be:
Application Requirement βRelevant Boolean βSecurity Impact βApproved Change βValidationDo not enable unrelated booleans simply to make an application work.
Phase 54 β AppArmor Hardening
Section titled βPhase 54 β AppArmor HardeningβOn AppArmor systems review:
Loaded Profiles
Enforcing Profiles
Complain Profiles
Unconfined ApplicationsThe goal is:
Application βApproved Behavior βEnforced PolicyPhase 55 β Logging Hardening
Section titled βPhase 55 β Logging HardeningβA hardened system must be observable.
Review:
System Logs
Authentication Logs
sudo Activity
Application Logs
Firewall Logs
Security Control EventsLogging Model
Section titled βLogging ModelβEVENT βLOCAL LOG βCENTRAL COLLECTOR βSIEM βDETECTION βINVESTIGATIONPhase 56 β Protect Logs
Section titled βPhase 56 β Protect LogsβConsider:
Ownership
Permissions
Retention
Rotation
Disk Capacity
Remote Forwarding
Tamper ResistanceLogs should not become:
Disk Exhaustion Riskor be easily altered by inappropriate identities.
Phase 57 β Centralize Logs
Section titled βPhase 57 β Centralize LogsβWhere architecture supports it, forward important events to a centralized platform.
Benefits:
Cross-System Correlation
Longer Retention
Incident Investigation
Detection
Reduced Local Tampering RiskPhase 58 β Harden Auditing
Section titled βPhase 58 β Harden AuditingβWhere Linux audit is required:
systemctl status auditdReview rules where authorized:
sudo auditctl -lAudit important events according to organizational requirements.
Potential categories include:
Identity Changes
Privilege Changes
Security Configuration
Sensitive File Changes
Administrative ActionsAudit Principle
Section titled βAudit PrincipleβDo not collect:
Everythingwithout planning.
Excessive auditing can create:
Noise
Storage Consumption
Performance Impact
Investigation DifficultyPhase 59 β Time Synchronization
Section titled βPhase 59 β Time SynchronizationβReview:
timedatectlA hardened server should have reliable time synchronization.
This supports:
Authentication
Logging
Incident Response
Certificate Validation
Distributed SystemsPhase 60 β Scheduled Task Hardening
Section titled βPhase 60 β Scheduled Task HardeningβReview:
crontab -land:
systemctl list-timers --allFor each scheduled task:
Owner
Purpose
Command
Script Ownership
Script Permissions
ScheduleImportant
Section titled βImportantβA root-owned scheduled task that executes a script writable by a lower-privileged user creates a serious privilege boundary problem.
Phase 61 β systemd Hardening
Section titled βPhase 61 β systemd HardeningβReview custom service units for:
User
Group
Executable
Working Directory
Environment
Restart Behavior
Dependencies
File PermissionsWhere supported by the workload, systemd can provide additional service restrictions.
Apply them only after compatibility testing.
Phase 62 β Protect Secrets
Section titled βPhase 62 β Protect SecretsβNever store secrets casually in:
Shell Scripts
World-Readable Files
Source Code
Shell History
Shared Home DirectoriesBetter Model
Section titled βBetter ModelβApplication βApproved Secret Manager βAuthorized Identity βRequired SecretPhase 63 β Review Configuration Files for Secrets
Section titled βPhase 63 β Review Configuration Files for SecretsβDo not indiscriminately copy application configuration into assessment evidence.
Instead determine:
Where Are Secrets Stored?
Who Can Read Them?
Are They Encrypted?
Can They Be Rotated?
Are They Shared?Phase 64 β Protect Private Keys
Section titled βPhase 64 β Protect Private KeysβPrivate keys require:
Restricted Access
Controlled Storage
Lifecycle Management
Rotation
RevocationNever place private key material into tickets, screenshots, or routine hardening reports.
Phase 65 β Backup Hardening
Section titled βPhase 65 β Backup HardeningβA hardened server should be recoverable.
Review:
Backup Scope
Frequency
Encryption
Access Control
Retention
Isolation
Restore TestingBackup Threat Model
Section titled βBackup Threat ModelβAn attacker with administrative access may attempt to:
Encrypt Backups
Delete Backups
Corrupt Backups
Steal BackupsTherefore backups require their own security controls.
Phase 66 β Separate Backup Privilege
Section titled βPhase 66 β Separate Backup PrivilegeβWhere architecture permits:
Production Administratorshould not automatically have unrestricted destructive control over every backup copy.
Consider:
Separate Credentials
Immutable Storage
Offline Copies
Restricted Deletionaccording to business requirements.
Phase 67 β Validate Restore
Section titled βPhase 67 β Validate RestoreβA backup is not proven until:
Restore WorksPeriodically test:
Configuration Recovery
File Recovery
Application Recovery
Full Server RecoveryPhase 68 β Install Security Monitoring Where Required
Section titled βPhase 68 β Install Security Monitoring Where RequiredβDepending on the environment, controls may include:
EDR
File Integrity Monitoring
Vulnerability Agent
Runtime Security
Security Logging
Configuration MonitoringThe correct controls depend on:
Threat Model
Server Role
Performance
Compliance
ArchitecturePhase 69 β File Integrity Monitoring
Section titled βPhase 69 β File Integrity MonitoringβImportant security-sensitive locations may include:
SSH Configuration
sudo Configuration
Authentication Configuration
Service Units
Application ConfigurationThe objective is to detect:
Unexpected Changenot to generate alerts for every legitimate deployment.
Phase 70 β Vulnerability Management
Section titled βPhase 70 β Vulnerability ManagementβA hardened system should participate in a recurring vulnerability-management process:
Discover βAssess βPrioritize βRemediate βRetestPrioritize Using Context
Section titled βPrioritize Using ContextβConsider:
Known Exploitation
Network Exposure
Privilege
Asset Criticality
Data Sensitivity
Compensating Controlsnot just a numeric vulnerability score.
Phase 71 β Configuration Management
Section titled βPhase 71 β Configuration ManagementβManual hardening does not scale well.
A mature environment moves toward:
Approved Baseline βAnsible / Configuration Management βServer Fleet βValidation βDrift DetectionRHCE Connection
Section titled βRHCE ConnectionβThis connects directly to the RHCE skills you studied earlier.
Instead of manually configuring:
100 Serversyou define:
Desired Secure Stateand apply it consistently.
Phase 72 β Version Control
Section titled βPhase 72 β Version ControlβSecurity configurations should be version controlled where appropriate.
Benefits:
Change History
Peer Review
Rollback
Auditability
ConsistencyNever commit:
Passwords
Private Keys
Tokens
Unencrypted Secretsto source control.
Phase 73 β Golden Images
Section titled βPhase 73 β Golden ImagesβCloud and enterprise environments may create:
Hardened Base Imagecontaining:
Approved OS
Security Baseline
Logging
Monitoring
Required Agents
Minimal PackagesNew servers inherit a known baseline.
Phase 74 β Immutable Infrastructure
Section titled βPhase 74 β Immutable InfrastructureβA mature model may move from:
Repair Server Manuallytoward:
Update Image βDeploy Replacement βRemove Old InstanceThis reduces configuration drift.
Phase 75 β Cloud Linux Hardening
Section titled βPhase 75 β Cloud Linux HardeningβCloud-hosted Linux requires two layers.
Cloud Security +Linux SecurityConsider:
IAM Role
Security Groups
VPC
EBS Encryption
CloudTrail
CloudWatch
Systems Manager
Instance Metadata SecurityConsider:
Managed Identity
Azure RBAC
NSGs
Disk Encryption
Defender for Cloud
Azure MonitorGoogle Cloud
Section titled βGoogle CloudβConsider:
Service Accounts
IAM
VPC Firewall
OS Login
Cloud Logging
Cloud MonitoringCloud Hardening Model
Section titled βCloud Hardening ModelβIDENTITY βCLOUD CONTROL PLANE βNETWORK βLINUX βAPPLICATION βDATAPhase 76 β Container Host Hardening
Section titled βPhase 76 β Container Host HardeningβIf Linux hosts containers, additionally assess:
Container Runtime
Registry Trust
Image Sources
Privileged Containers
Capabilities
Mounts
Host Networking
Secrets
Runtime MonitoringPhase 77 β Kubernetes Node Hardening
Section titled βPhase 77 β Kubernetes Node HardeningβFor Kubernetes Linux nodes consider:
Node Access
Kubelet
Container Runtime
Host Firewall
Kernel
Logging
Cloud IAM
Runtime SecurityAvoid treating Kubernetes nodes exactly like general-purpose user servers.
Phase 78 β Validate Hardening
Section titled βPhase 78 β Validate HardeningβAfter implementing approved changes, repeat the baseline.
Review:
sudo ss -lntupsystemctl --type=service --state=runningsystemctl list-unit-files --type=service --state=enabledThen validate:
SSH
Firewall
Application
Logging
Security Controls
Scheduled Tasks
MonitoringPhase 79 β Functional Testing
Section titled βPhase 79 β Functional TestingβSecurity controls are successful only if:
Security Improvedand:
Required Business FunctionStill WorksTest:
Application Access
Administrative Access
Monitoring
Backups
Scheduled Jobs
DependenciesPhase 80 β Negative Security Testing
Section titled βPhase 80 β Negative Security TestingβAlso test what should no longer work.
Examples:
Unauthorized UserCannot Read Sensitive Data
Unapproved SourceCannot Reach SSH
Removed ServiceNo Longer Listens
Standard UserCannot Perform Admin ActionPhase 81 β Reboot Validation
Section titled βPhase 81 β Reboot ValidationβSome changes appear correct until reboot.
Where approved and operationally safe, validate persistence after restart.
Check:
Services
Mounts
Firewall
Network
SELinux/AppArmor
Logging
Application
MonitoringPhase 82 β Compare Before and After
Section titled βPhase 82 β Compare Before and AfterβBuild a hardening matrix:
| Control | Before | After | Status |
|---|---|---|---|
| Unsupported accounts | Present | Removed/disabled | Improved |
| SSH exposure | Broad | Restricted | Improved |
| Unnecessary service | Running | Disabled | Improved |
| Firewall | Permissive | Restricted | Improved |
| MAC | Review | Enforcing | Improved |
| Logging | Local | Centralized | Improved |
Phase 83 β Record Exceptions
Section titled βPhase 83 β Record ExceptionsβNot every baseline control can always be implemented.
Document:
Control
Reason
Business Owner
Security Risk
Compensating Control
Approval
Expiration
Review DatePhase 84 β Compensating Controls
Section titled βPhase 84 β Compensating ControlsβSuppose an application cannot support a particular host hardening requirement.
Possible compensating controls might include:
Network Restriction
Additional Monitoring
Application Firewall
Stronger IAM
Dedicated Host
Increased LoggingThe compensating control should address the actual risk.
Phase 85 β Hardening Finding Closure
Section titled βPhase 85 β Hardening Finding ClosureβA finding should move through:
OPEN βREMEDIATION PLANNED βIMPLEMENTED βRETESTED βCLOSEDNot:
OPEN βEngineer Says Fixed βCLOSEDPhase 86 β Hardening Report
Section titled βPhase 86 β Hardening ReportβCreate:
Linux Server Hardening ReportInclude the following sections.
1. Executive Summary
Section titled β1. Executive SummaryβDocument:
Server
Business Role
Hardening Objective
Overall Result
Residual Risk2. Scope
Section titled β2. ScopeβDocument:
Operating System
Applications
Security Controls
Excluded Components3. Baseline
Section titled β3. BaselineβIdentify:
Organizational Standard
Vendor Guidance
Applicable Benchmark4. Pre-Hardening State
Section titled β4. Pre-Hardening StateβSummarize major weaknesses.
5. Changes Implemented
Section titled β5. Changes ImplementedβFor every change:
Control
Original State
New State
Reason
Validation6. Security Improvements
Section titled β6. Security ImprovementsβExamples:
Reduced Attack Surface
Reduced Privilege
Restricted SSH
Improved Firewall
Improved Logging
Improved Recovery7. Exceptions
Section titled β7. ExceptionsβDocument approved deviations.
8. Residual Risk
Section titled β8. Residual RiskβExplain risks that remain after hardening.
9. Validation
Section titled β9. ValidationβDocument:
Functional Testing
Security Testing
Reboot Testing
Monitoring Validation10. Recommendations
Section titled β10. RecommendationsβInclude:
Immediate
Operational
Long-TermPhase 87 β Hardening Checklist
Section titled βPhase 87 β Hardening ChecklistβPreparation
Section titled βPreparationβ- Authorization confirmed
- Server role understood
- Application owner identified
- Baseline selected
- Change window approved
- Recovery access confirmed
- Rollback plan prepared
- Backup verified
- OS support reviewed
- Kernel reviewed
- Security updates reviewed
- Approved repositories confirmed
- Unnecessary packages reviewed
Identity
Section titled βIdentityβ- User accounts reviewed
- Dormant accounts addressed
- UID 0 reviewed
- Service accounts reviewed
- Interactive login reviewed
- Administrative identities reviewed
Privilege
Section titled βPrivilegeβ- sudo reviewed
- Excessive privilege removed
- Administrative groups reviewed
- NOPASSWD reviewed
- SUID reviewed
- SGID reviewed
- SSH required
- Effective configuration reviewed
- Root login reviewed
- Authentication methods reviewed
- Authorized keys reviewed
- Users/groups reviewed
- Network exposure restricted
- Configuration validated before reload
- Recovery session maintained during change
Filesystem
Section titled βFilesystemβ- Sensitive files reviewed
- World-writable files reviewed
- Shared directories reviewed
- Home directories reviewed
- ACLs reviewed
- umask reviewed
- Mount options reviewed
Services
Section titled βServicesβ- Running services inventoried
- Enabled services inventoried
- Unnecessary services addressed
- Service ownership established
- Service dependencies validated
Network
Section titled βNetworkβ- Interfaces reviewed
- Routes reviewed
- IPv4 reviewed
- IPv6 reviewed
- Listening ports reviewed
- IP forwarding reviewed
- Kernel network controls reviewed
- Outbound requirements reviewed
Firewall
Section titled βFirewallβ- Firewall active
- Required services documented
- Management access restricted
- Unnecessary rules removed
- IPv6 considered
- New administrative session tested
Mandatory Access Control
Section titled βMandatory Access Controlβ- SELinux/AppArmor state reviewed
- Required policies enforcing
- Exceptions documented
- Application compatibility validated
Logging
Section titled βLoggingβ- System logging working
- Authentication logging working
- sudo activity visible
- Application logging reviewed
- Central forwarding reviewed
- Retention reviewed
- Log permissions reviewed
Auditing
Section titled βAuditingβ- Audit requirement defined
- Audit service reviewed
- Security-relevant rules reviewed
- Audit retention reviewed
- Monitoring integration reviewed
- Timezone correct
- Time synchronization active
- Central systems use compatible time
Persistence
Section titled βPersistenceβ- Cron reviewed
- systemd timers reviewed
- Enabled services reviewed
- SSH keys reviewed
- Startup configuration reviewed
Secrets
Section titled βSecretsβ- Plaintext secrets reviewed
- Secret permissions reviewed
- Private keys protected
- Approved secret-management process used
- Secret rotation available
Recovery
Section titled βRecoveryβ- Backups active
- Backup access restricted
- Backup encryption reviewed
- Backup isolation reviewed
- Restore tested
Monitoring
Section titled βMonitoringβ- Security telemetry enabled
- Vulnerability management active
- File integrity monitoring considered
- Endpoint/runtime monitoring considered
- Alerts validated
Validation
Section titled βValidationβ- Application tested
- SSH tested
- Firewall tested
- Required ports tested
- Unauthorized access tested
- Logging tested
- Monitoring tested
- Reboot persistence validated where approved
Documentation
Section titled βDocumentationβ- Changes recorded
- Evidence collected
- Exceptions documented
- Residual risks documented
- Rollback information recorded
- Hardening report completed
Common Hardening Mistakes
Section titled βCommon Hardening MistakesβAvoid:
Blindly Applying CIS Settings
Changing SSH Without Console Access
Applying Firewall Rules Before Allowing Management
Using chmod 777 to Fix Applications
Disabling SELinux
Disabling AppArmor
Removing Unknown Services Without Investigation
Deleting Service Accounts Without Dependency Review
Ignoring IPv6
Ignoring Egress
Ignoring Secrets
Ignoring Backups
Hardening Without Application Testing
Hardening Without Rollback
Hardening Once and Never Checking AgainHardening Is Continuous
Section titled βHardening Is ContinuousβA hardened server today may drift tomorrow.
Why?
New Package
New Administrator
Application Change
Emergency Fix
New Firewall Rule
New Service
Configuration ChangeTherefore:
HARDEN βMONITOR βDETECT DRIFT βREMEDIATE βVALIDATEConfiguration Drift
Section titled βConfiguration DriftβExample:
Approved State
SSH:Management Network OnlyLater:
Temporary Troubleshooting Change
SSH:Any SourceThen the temporary change is forgotten.
That is:
Configuration DriftContinuous Compliance
Section titled βContinuous ComplianceβMature environments automate:
Baseline βConfiguration Assessment βDrift Detection βAlert βRemediationSecurity Automation
Section titled βSecurity AutomationβAs environments grow:
1 Servermay be manageable manually.
But:
10 Servers
100 Servers
1,000 Serversrequire automation.
Tools and approaches may include:
Ansible
Configuration Management
Policy as Code
Infrastructure as Code
Compliance AutomationZero Trust Connection
Section titled βZero Trust ConnectionβLinux hardening supports Zero Trust principles:
Verify Identity
Least Privilege
Minimize Access
Segment Networks
Monitor Activity
Assume BreachDefense in Depth
Section titled βDefense in DepthβNo single Linux control should carry the entire security burden.
Use:
PATCHING +IAM +sudo +SSH +PERMISSIONS +FIREWALL +SELINUX / APPARMOR +LOGGING +MONITORING +BACKUPSInterview Scenario 01
Section titled βInterview Scenario 01βHow would you harden a new Linux production server?
Use:
Understand Role βBaseline βBackup βPatch βIdentity βPrivilege βSSH βFilesystem βServices βNetwork βFirewall βMAC βLogging βMonitoring βBackup βValidateInterview Scenario 02
Section titled βInterview Scenario 02βWhy shouldnβt you blindly apply CIS controls?
Because a security control may affect:
Application Compatibility
Availability
Operations
PerformanceControls must be evaluated against the actual workload.
Interview Scenario 03
Section titled βInterview Scenario 03βHow do you safely harden SSH remotely?
Maintain:
Existing Session +Console/Recovery AccessThen:
Modify βValidate sshd Configuration βReload βOpen New Session βVerify βClose Old SessionInterview Scenario 04
Section titled βInterview Scenario 04βWhy shouldnβt SELinux simply be disabled when an application fails?
Because SELinux may be correctly preventing behavior outside the intended policy.
Investigate:
Permissions
Context
Logs
Policy
Boolean
Application Behaviorand correct the underlying issue.
Interview Scenario 05
Section titled βInterview Scenario 05βHow do you know hardening worked?
By comparing:
BEFOREand:
AFTERand performing:
Configuration Validation
Functional Testing
Negative Security Testing
Monitoring Validation
Persistence Testing40 Linux Server Hardening Interview Questions
Section titled β40 Linux Server Hardening Interview Questionsβ- What is Linux server hardening?
- What is attack-surface reduction?
- Why must server role be understood first?
- What is a hardening baseline?
- Why should benchmarks not be applied blindly?
- Why is rollback important?
- Why should a pre-hardening baseline be captured?
- How does patching improve security?
- Why should repositories be reviewed?
- Why remove unnecessary packages?
- How do you harden user accounts?
- What is a dormant account?
- Why are UID 0 accounts important?
- How should service accounts be hardened?
- What is least privilege?
- How do you safely modify sudo?
- Why is
visudouseful? - How would you harden SSH?
- Why should SSH root login be reviewed?
- Why are SSH keys security-sensitive?
- Why should SSH network exposure be restricted?
- Why is
chmod 777dangerous? - What are SUID and SGID?
- What is umask?
- What do
nodev,nosuid, andnoexecconceptually provide? - How do you reduce service attack surface?
- How do you identify listening ports?
- Why should IP forwarding be reviewed?
- How do you harden a host firewall?
- Why should outbound access be reviewed?
- What is SELinux?
- Why should SELinux remain enforcing where required?
- What is AppArmor?
- Why is centralized logging important?
- What is Linux auditing?
- Why is time synchronization important?
- How should secrets be protected?
- Why are secure backups part of hardening?
- What is configuration drift?
- How would you validate Linux hardening?
Runbook Completion Criteria
Section titled βRunbook Completion CriteriaβLinux hardening is complete only when you can demonstrate:
Supported Operating System
Security Updates Managed
Accounts Controlled
Privilege Minimized
SSH Restricted
Sensitive Files Protected
Unnecessary Services Reduced
Network Exposure Restricted
Firewall Enforced
Mandatory Access Control Operating
Security Events Logged
Auditing Appropriate
Secrets Protected
Backups Recoverable
Monitoring Active
Configuration Validated
Exceptions DocumentedFinal Linux Hardening Mental Model
Section titled βFinal Linux Hardening Mental ModelβMemorize:
KNOW THE SERVER βREDUCE SOFTWARE βREDUCE USERS βREDUCE PRIVILEGE βREDUCE SERVICES βREDUCE PORTS βRESTRICT NETWORK βPROTECT FILES βENFORCE SECURITY CONTROLS βLOG IMPORTANT ACTIVITY βMONITOR CHANGE βPROTECT RECOVERY βVALIDATE EVERYTHINGRunbook Success Criteria
Section titled βRunbook Success CriteriaβA successful Linux hardening engagement produces:
Approved Baseline
Pre-Hardening Evidence
Change Plan
Rollback Plan
Patched System
Hardened IAM
Hardened SSH
Protected Filesystem
Reduced Services
Restricted Network
Host Firewall
SELinux/AppArmor Enforcement
Logging and Auditing
Protected Secrets
Secure Backups
Monitoring
Post-Hardening Validation
Exception Register
Hardening ReportLinux Security Operations Lifecycle
Section titled βLinux Security Operations LifecycleβYour three runbooks now form a complete operational lifecycle:
Runbook 01Linux Incident Investigation β"What Happened?"
Runbook 02Linux Security Assessment β"What Is Weak?"
Runbook 03Linux Server Hardening β"How Do We Secure It?"Together:
ASSESS βHARDEN βMONITOR βDETECT βINVESTIGATE βREMEDIATE βVALIDATE βIMPROVELinux Learning Path Complete
Section titled βLinux Learning Path CompleteβYou have now completed the Linux certification, lab, and operational runbook sequence.
LINUX CERTIFICATION ROADMAP βLinux Essentials βLPIC-1 βCompTIA Linux+ βRHCSA βRHCE βLINUX LABS βLinux Administration βLinux Hardening βLinux IAM βLinux Networking βLinux Security βLINUX RUNBOOKS βLinux Incident Investigation βLinux Security Assessment βLinux Server HardeningYou have progressed from:
Linux Fundamentalsthrough:
Linux Administrationinto:
Enterprise Linux βAutomation βSecurity βAssessment βIncident Response βHardeningWhatβs Next?
Section titled βWhatβs Next?ββ‘οΈ Linux Security Path Complete
You now have a Linux foundation that directly supports the broader GoHackersCloud career paths:
Linux βββ Cybersecurity βββ SOC Operations βββ Ethical Hacking βββ Cloud Security βββ DevSecOps βββ Container Security βββ Kubernetes Security βββ Incident Response βββ Security EngineeringThe most important outcome is not memorizing commands.
It is developing the ability to look at a Linux system and systematically ask:
What Should Be Here?
What Is Actually Here?
What Is Exposed?
Who Has Access?
What Is Over-Privileged?
What Can Be Removed?
What Must Be Protected?
What Can We Detect?
Can We Investigate?
Can We Recover?
Can We Prove the System Is Secure?That is the mindset of a professional Linux security engineer.