Skip to content

StrangeRanger/linux-security-scripts

Repository files navigation

Linux Security Scripts

Project Tracker Style Guide Codacy Badge

This repository is a collection of scripts designed to secure/harden Linux-based distributions.

Table of Contents

Tools and Scripts

Below is a list of tools included in this repository.

Tool Name Description Category Requirements Notes
Lynis Installer Download (clone) Lynis, a security auditing tool for Unix-like systems. Auditing Git, Internet connection No root required
Root Locker Locks the root account to prevent direct logins. Hardening Root privileges Preserves sudo access
SSHD Hardening Harden OpenSSH server (sshd) per Lynis recommendations. Hardening Root privileges Creates backups
UFW Cloudflare Configure UFW to only allow HTTP/HTTPS from Cloudflare IP ranges. Hardening Root privileges, UFW, Internet connection Creates backups

Note

All scripts include version information in their headers. Check individual CHANGELOG.md files in each tool's directory for version history and updates.

Getting Started

Prerequisites

The following requirements extend to every tool in this repository:

  • Bash: Version 4.0 or higher
  • Operating System: Linux-based distribution

Note

Individual scripts may have additional requirements listed in the table above.

Download and Setup

All you need to do is download this repository to your local machine:

git clone https://github.com/StrangeRanger/linux-security-scripts
cd linux-security-scripts

Usage

Quick Start

For users who want to get started immediately:

  1. Audit your system first: Run the Lynis installer to download the auditing tool.

    ./auditing/Lynis\ Installer/lynis-installer.bash
  2. Run a security audit: Use Lynis to identify security issues.

    cd ~/lynis && sudo ./lynis audit system
  3. Apply hardening: Based on the audit results, run the appropriate hardening scripts with root privileges.

Caution

Production Environment Warning: Always test scripts in a non-production environment first. Some scripts modify critical system configurations and may affect system accessibility.

Individual Script Usage

You can run any script individually using one of the following methods:

./[script-name]

or

bash [script-name]

Post-Installation

After running the hardening scripts:

  1. Verify SSH access: Before logging out, test SSH connectivity in a new terminal session.
  2. Review firewall rules: Check UFW status with sudo ufw status verbose if you used the UFW Cloudflare script.
  3. Run Lynis again: Re-audit your system to see security improvements.
  4. Backup configurations: Keep copies of any modified configuration files.

Warning

The SSHD hardening script modifies SSH configurations. Ensure you have alternative access to your system before applying changes in production environments.

Tested On

All of the scripts should work on most, if not all, Linux distributions with Bash v4.0+ installed. With that said, below is a list of Linux distributions that the scripts have been officially tested and are confirmed to work on.

Distributions Distro Versions
Ubuntu 24.04, 22.04, 20.04
Debian 11, 10, 9

Other Resources

Below is a list of additional resources that you can/should use to help make your system as secure as possible.

Security Auditing Tools

  • SSH Audit - SSH server & client auditing (banner, key exchange, encryption, mac, compression, compatibility, security, etc)

Additional Hardening Resources

System Monitoring

  • AIDE - Advanced Intrusion Detection Environment
  • Fail2Ban - Intrusion prevention software
  • rkhunter - Rootkit detection tool

Support and Issues

Please use GitHub Issues for bug reports and feature requests.

License

Licensing may vary by tool; see individual file headers.

About

A collection of scripts designed to secure/harden Linux based distributions

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •  

Languages