How hosteons/linux-hardening-script works
1. Repository shape
- This is a very small, single-purpose repository: one shell entrypoint (harden.sh), documentation, and a license.
- The architecture is not a multi-service app; it is a local host automation script that directly modifies the machine it runs on.
2. Primary runtime boundary
- The script runs on the target Linux VPS/server itself with administrative privileges.
- There is no separate backend, API, database, or UI layer. The “system under management” is the Linux host.
3. Supported environments
- The script targets four Linux families: Ubuntu, Debian, CentOS, and AlmaLinux.
- That implies distro-aware branching around package management, firewall/SELinux behavior, and SSH service configuration.
4. Main orchestration role of harden.sh
- harden.sh is the central orchestrator for all hardening tasks.
- It likely runs as a linear workflow: update the system, apply security changes, install hardening tools, then run an audit.
5. Operational input boundary
- The operator is part of the architecture: the script prompts for choices such as SSH port changes, root login disabling, and new sudo user setup.
- The script is therefore partially interactive, with safety-sensitive decisions made at runtime rather than predeclared config.
6. System update and package-management flow
- One subsystem is the update/install layer, which brings the host to a current state before hardening.
- This layer interacts with the OS package manager and is the dependency foundation for all later steps.
7. SSH hardening subsystem
- SSH is a central security boundary in this repo.
- The script can change the SSH port and optionally disable root login, which directly affects remote access and remote administration paths.
8. Access-control / user-management subsystem
- Another branch of the workflow is sudo user provisioning.
- The script can create or prepare a non-root administrative user, shifting privileged access away from direct root use.
9. Firewall and network exposure subsystem
- The script configures the host firewall, which is the main network-layer enforcement boundary.
- This subsystem works together with the SSH changes to reduce exposed services and constrain inbound access.
10. Brute-force protection and audit tooling
- The repo installs and uses Fail2Ban for intrusion prevention and Lynis for security auditing.
- Fail2Ban is a reactive protection layer; Lynis is a post-change validation/audit layer.
11. SELinux handling
- For CentOS/AlmaLinux, SELinux is explicitly part of the hardening model.
- This introduces an OS security-policy layer distinct from firewalling and SSH config, so architecture diagrams should show it as a separate host-control boundary.
12. Execution outcome
- The script’s output is a hardened server state rather than an ongoing service.
- The main data flow is: operator input → system changes on the host → security tools installed/configured → audit feedback from Lynis.
13. External dependencies
- The only meaningful external dependencies are OS-level services and tools: SSH daemon, firewall tooling, package managers, Fail2Ban, Lynis, and SELinux.
- Hosteons appears only as attribution in the README and does not change the runtime architecture.
14. What to diagram
- For an architecture diagram, treat this repo as a single automation component connected to one target machine.
- Show the operator feeding decisions into harden.sh, and the script driving changes to system packages, SSH, firewall, SELinux, and security tooling on the local server.
Main entry points: harden.sh harden.sh
Components 15
Repository
The automation entrypoint and documentation in this project.
- harden.sh · Main shell workflow that applies host hardening steps.
harden.sh
Target Host
The Linux server being modified in place by the script.
- Package Layer · OS package management and baseline updates before hardening.
- Distro Rules · Ubuntu, Debian, CentOS, and AlmaLinux-specific handling.
- SSH Daemon · Remote administration service whose config is hardened.
- SSH Policy · Port changes and root-login restrictions for SSH access.
- Sudo User · Non-root administrative account prepared for safer access.
- Firewall · Inbound network filtering aligned with the SSH policy.
- SELinux · Mandatory access control handling on CentOS and AlmaLinux.
- Hardened Host · Final secured server state after changes and audit.
- Pkg Manager · Underlying distro package manager used to install and update components.
Security Tools
External host-level tools and services used during hardening.
- Fail2Ban · Brute-force protection for exposed services, especially SSH.
- Lynis · Post-change audit and validation of the hardened host.
Other components
- Operator · Admin choosing hardening options at runtime.
- SSH Port · Interactive choice controlling the remote access endpoint.
- Root Login · Interactive choice to keep or disable root SSH access.
Connections 21
- Operator → harden.sh: runs · The operator starts the hardening workflow on the target host.
- Operator → SSH Port: chooses · Runtime input for SSH port selection.
- Operator → Root Login: chooses · Runtime input for root SSH login policy.
- harden.sh → Distro Rules: detects · Branches behavior by Linux family.
- harden.sh → Package Layer: updates · Brings the base system current before hardening.
- Package Layer → Pkg Manager: uses · Relies on the host package manager.
- harden.sh → SSH Policy: configures · Applies SSH hardening choices and policy.
- SSH Policy → SSH Daemon: controls · Updates the SSH service behavior.
- SSH Port → SSH Policy: feeds · Selected port is written into SSH policy.
- Root Login → SSH Policy: feeds · Chosen root-login policy is written into SSH policy.
- harden.sh → Sudo User: provisions · Sets up or prepares a non-root admin account.
- harden.sh → Firewall: enforces · Configures inbound filtering and port exposure.
- SSH Policy → Firewall: aligns · Firewall rules must match the SSH access path.
- harden.sh → SELinux: handles · Adjusts SELinux-related behavior on supported distros.
- Distro Rules → SELinux: gates · SELinux handling is specific to CentOS and AlmaLinux.
- harden.sh → Fail2Ban: installs · Adds brute-force protection for exposed services.
- harden.sh → Lynis: audits · Runs a security audit after hardening steps.
- Lynis → Hardened Host: validates · Audit feedback reflects the resulting host posture.
- Fail2Ban → Hardened Host: protects · Reactive protection contributes to the final hardened state.
- Firewall → Hardened Host: constrains · Network exposure is reduced in the final state.
- SSH Daemon → Hardened Host: serves · SSH remains the managed remote-access boundary.