Skip to main content

AI-powered Linux security configuration auditor

Project description

Hardin Pilot Logo

Hardin Pilot

AI-Powered Linux Security Configuration Auditor

Hardin Pilot is a robust, automated CLI tool that scans your Linux system for configuration files across 55+ services, deeply analyzes them using advanced AI models, and generates comprehensive PDF security reports alongside actionable remediation commands.

Python 3.10+ License: MIT


[!CAUTION] IMPORTANT NOTE REGARDING AI MODELS This tool was exclusively vetted, QA'd, and optimized over hours of rigorous testing using the gemini-2.5-flash model (specifically utilizing its deep "thinking" capabilities).

We strongly advise sticking to Google Gemini as your primary provider. While other API providers (like OpenAI, Groq, or Local LMStudio endpoints) are technically supported via the setup menu, their JSON parsing abilities have not been extensively tested and they may act unpredictably when handling complex, multi-layered Linux configurations. Use them at your own risk.


๐ŸŒŸ Key Features

  • Massive Discovery Scanner: Automatically detects configuration files for 55+ standard Linux services (SSH, Nginx, Apache, MySQL, Docker, Kubernetes, etc.) and gracefully handles custom conf.d structures.
  • Provider-Agnostic Deep AI Analysis: Supports Google Gemini (free-tier out of the box), OpenAI (ChatGPT), or Local / Custom APIs (LMStudio, Ollama, DeepSeek, Groq). Hardin utilizes deep "thinking" cognitive layers (where available) to reason through complex misconfigurations.
  • Auto-Remediation Workflow: Doesn't just find problems. Hardin generates exact, safe terminal commands (sed, etc.) to instantly fix all discovered vulnerabilities. It saves these to ~/.hardin/last_remediation.sh so you can review your PDF first and independently execute the fixes later with pyhardin --apply.
  • FastAPI + HTMX Dashboard: Prefer a GUI over the terminal? Pyhardin includes a blazing-fast, lightweight web dashboard. Run pyhardin --gui to review findings, tweak API settings, view prompts in structured tables, and download PDFs straight from your browser.
  • Beautiful PDF Reporting: Compiles service-by-service findings into a clean, merged, professional PDF document for compliance and review.
  • Stateful Crash Recovery: Network interrupted? Rate-limited? Hardin tracks progress. Just re-run the tool and it picks up exactly where it left off.
  • Rich Interactive CLI: Beautiful terminal output with progress bars, severity color-coding, and an interactive first-time setup wizard.

๐Ÿ› ๏ธ Tech Stack

  • Core Language: Python 3.10+
  • AI Integration: google-genai and openai SDKs
  • Reporting Generator: reportlab & PyPDF2
  • CLI Framework: rich, rich.prompt, & standard argparse
  • Web Dashboard: fastapi, htmx, tailwind-css, jinja2, and aiofiles

๐Ÿ“ฆ Prerequisites

  • A Linux environment (Ubuntu/Debian, CentOS, RHEL, Arch, WSL2, MacOS)
  • Python 3.10 or higher
  • An API Key from Google (Gemini) or a compatible LLM provider

๐Ÿš€ Getting Started

1. PyPI (Recommended)

Hardin is available on the official Python Package Index. You can install the core lightweight CLI locally via pip or pipx:

# Core CLI only (Ultra-lightweight)
pip install pyhardin

# CLI + Web GUI Dashboard
pip install "pyhardin[gui]"

2. Alternative Package Managers

If you prefer to isolate Pyhardin in its own environment, you can use any of the popular package managers:

Using pip and venv

python3 -m venv .venv
source .venv/bin/activate
pip install pyhardin

Using uv

uv venv
source .venv/bin/activate
uv pip install pyhardin

Using pipenv

pipenv install pyhardin
pipenv shell
pyhardin

Using conda

conda create -n hardin-env python=3.10
conda activate hardin-env
pip install pyhardin

3. The Automated Installer (From Source)

The absolute fastest way to get Hardin running from source is to use the included installation script. This script automatically updates package lists, ensures python3-venv is present, creates an isolated environment, and installs the tool globally on your path.

# Clone the repository
git clone https://github.com/0xMesh-X/hardin-pilot.git
cd hardin-pilot

# Run the automated install script
chmod +x install.sh
sudo ./install.sh

# Run from anywhere!
pyhardin

4. Manual Installation (Development)

If you prefer to manage the source code yourself:

# Clone and enter directory
git clone https://github.com/0xMesh-X/hardin-pilot.git
cd hardin-pilot
python3 -m venv .venv
source .venv/bin/activate

# Install dependencies and the tool
pip install -e .

# Launch Hardin
pyhardin

โš™๏ธ Configuration & Usage

The first time you run hardin, an interactive wizard will launch to help you configure your preferred AI provider.

The Setup Wizard

pyhardin

The wizard will ask you to choose between:

  1. Google Gemini: The default. Generous free tier via Google AI Studio. (Includes choices like gemini-2.5-flash, gemini-2.5-pro, and gemini-2.0-flash-thinking-exp). Provide the number matching your choice.
  2. OpenAI: For those with ChatGPT/OpenAI API keys. (Experimental).
  3. Local / Custom API: For offline, private AI (like LMStudio running on http://localhost:1234/v1) or alternative providers (like Groq or DeepSeek). (Experimental).

The wizard will provide you the exact URL where you can generate the required API key based on your choice. Configurations are saved securely to ~/.hardin/config.json.

CLI Commands

Command Description
pyhardin Runs the standard CLI interactive scan. Analyzes configs locally and generates the PDF.
pyhardin --gui New! Launches the FastAPI web dashboard at http://localhost:8000 for a rich visual experience.
pyhardin --gui --port 8080 Launches the web dashboard on a custom port instead of the default 8000.
pyhardin --apply Instantly executes the pending remediation script generated by your last complete scan.
pyhardin --show <ID> --show-prompts Views the detailed report (and LLM structured prompt tables) for a past scan ID.
pyhardin --delete <ID> Permanently deletes a specific scan report from local history.
pyhardin --list Scans the system and simply lists which services it found, without sending data to the AI.
pyhardin --history Displays a table of all your historical local CLI and GUI scans.
pyhardin --no-resume Clears previous tracking state and forces a fresh, complete scan from scratch.
pyhardin --resume-id <ID> Explicitly resumes a specific historical incomplete scan.
pyhardin --scan /path/to/extra/config Explicitly targets an extra directory to scan, in addition to the defaults.
pyhardin --set-key "" Explicitly overwrite the API key.
pyhardin --reset Wipes the entire local configuration (config.json) and state caches, forcing the interactive setup wizard to launch anew.

Remote Dashboard Access (Cloud Providers)

If you are running Pyhardin on a remote server and want to access the Web GUI (pyhardin --gui) from your local browser, you need to ensure Port 8000 (TCP) is open in both your server's local firewall and your cloud provider's network security group.

AWS (EC2)

  1. Go to the EC2 Dashboard -> Security Groups.
  2. Select the Security Group attached to your instance.
  3. Click Edit inbound rules -> Add rule.
  4. Type: Custom TCP, Port Range: 8000, Source: My IP (Recommended) or 0.0.0.0/0 (Anywhere).

Google Cloud (GCP)

  1. Go to VPC Network -> Firewall.
  2. Click Create Firewall Rule.
  3. Name: allow-hardin-8000, Targets: All instances in the network (or specific tags), Source filter: IPv4 ranges -> 0.0.0.0/0.
  4. Specified protocols and ports: Check tcp and type 8000.

Microsoft Azure

  1. Go to Virtual Machines -> Select your VM -> Networking.
  2. Click Add inbound port rule.
  3. Destination port ranges: 8000, Protocol: TCP, Action: Allow.

UFW / IPTables (Local Server Firewall)

If your Linux instance is also running a local firewall (like ufw), you must allow the port natively in the terminal before the dashboard can receive traffic:

sudo ufw allow 8000/tcp

๐Ÿ—๏ธ Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”     โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”     โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”     โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚   Scanner   โ”‚โ”€โ”€โ”€โ”€โ–ถโ”‚   Analyzer   โ”‚โ”€โ”€โ”€โ”€โ–ถโ”‚   Reporter   โ”‚โ”€โ”€โ”€โ”€โ–ถโ”‚   Output     โ”‚
โ”‚             โ”‚     โ”‚              โ”‚     โ”‚              โ”‚     โ”‚              โ”‚
โ”‚ Discovers   โ”‚     โ”‚ Routes to    โ”‚     โ”‚ Generates    โ”‚     โ”‚ Merged PDF   โ”‚
โ”‚ configs by  โ”‚     โ”‚ Gemini/OpenAIโ”‚     โ”‚ per-service  โ”‚     โ”‚ + bash fix   โ”‚
โ”‚ service     โ”‚     โ”‚              โ”‚     โ”‚ PDFs, merges โ”‚     โ”‚ remediation  โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜     โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜     โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜     โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
  1. Scan Phase (scanner.py): Traverses known paths (like /etc/ssh, /etc/nginx) checking for existence and reading file contents safely. Truncates massive files to prevent token overflows.
  2. Analysis Phase (analyzer.py): Injects the configuration text into a highly specific security prompt. Leverages the AI model's "thinking/reasoning" engines (if available) to evaluate the configs, ultimately extracting a clean JSON response.
  3. State Management (state.py): Intervenes between network calls to record progress instantly to ~/.hardin/state.json, protecting you against connection losses or hard-coded API Rate Limits.
  4. Reporting Phase (reporter.py): Renders beautifully stylized PDF pages (using Arial/Helvetica to avoid missing font errors) on a service-by-service basis and merges them into one cohesive compliance document. Auto-generates the remediation bash script to ~/.hardin/last_remediation.sh.
  5. CLI Logic Engine (cli.py): Orchestrates the rich visual interface, progress bars, API configuration workflows, argument parsing, and subprocess executions for applying fixes.

Supported Services

Hardin natively knows where to look for over 55 common configuration structures, including: ssh, nginx, apache2, mysql, postgresql, redis, samba, vsftpd, postfix, bind, dhcp, ntp, rsyslog, sudo, cron, pam, ufw, iptables, fail2ban, sysctl, fstab, docker, kubernetes, snmp, nfs, systemd, apparmor, selinux, modprobe, squid, openvpn, wireguard, mongodb, memcached, tomcat, php, haproxy... and a massive miscellaneous catch-all for any other .conf files living in root /etc/.


๐Ÿ”ง Troubleshooting

"Are my files being sent to the cloud?"

Yes, unless you use the Local / Custom API option. If you are auditing extremely sensitive production networks, it is recommended to run a local model like llama3 or qwen2.5-coder on a dedicated machine and point Hardin's API Base URL to it via the setup wizard.

"I'm hitting Rate Limits!"

Free-tier API keys limit how many requests you can make per minute and per day.

  • If it's a Per-Minute limit, Hardin will automatically pause, wait, and retry with exponential backoff.
  • If it's a Per-Day limit, Hardin will save your exact state. Wait 24 hours (or switch to a new provider) and just run hardin again to continue from exactly where you stopped.

"PDF Font Errors"

Hardin uses standard Helvetica and Helvetica-Bold built into PDF readers to avoid relying on external .ttf files that might not be installed on bare-bones server environments. PDF generation should work fluidly on entirely headless Linux boxes.


๐Ÿ“œ License

MIT License. See LICENSE for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyhardin-2.0.2.tar.gz (44.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyhardin-2.0.2-py3-none-any.whl (43.3 kB view details)

Uploaded Python 3

File details

Details for the file pyhardin-2.0.2.tar.gz.

File metadata

  • Download URL: pyhardin-2.0.2.tar.gz
  • Upload date:
  • Size: 44.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for pyhardin-2.0.2.tar.gz
Algorithm Hash digest
SHA256 2a82bb63fba159b6a308fd0cf65d8c5cb29789a5411e4167cb80cb72ab458c92
MD5 35ebe6563d5525313d7aeb2730dea19e
BLAKE2b-256 b1c4c4e4deb507888fd8d9690a6e1c48854d1ad758d07af79aecb3bbd4276de3

See more details on using hashes here.

File details

Details for the file pyhardin-2.0.2-py3-none-any.whl.

File metadata

  • Download URL: pyhardin-2.0.2-py3-none-any.whl
  • Upload date:
  • Size: 43.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for pyhardin-2.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 01a84ae12f84de7181c3d9f527a394f2d3e4ddfcdfe552e7f4ba613be1014dc6
MD5 af75dba6bc65c508ced2d91f065077a3
BLAKE2b-256 3d2993adb3f6e89205190156eedc2facadf76ad2bc98b0e929c1ea1d2add6671

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page