GaiaOpen source project
A fresh Linux server, hardened with a single command.
An administrator account with SSH keys, locked-down SSH, a firewall that closes everything that does not need to be open, fail2ban, automatic security updates, kernel and network hardening and a security audit before and after.
- Status
- In development
- License
- Apache-2.0
- Language
- Bash
- Version
- 0.1.0
01Why Gaia
Every new server on the internet gets login attempts within minutes.
The checklist to make it reasonably safe is always the same and easy to get wrong by hand: a forgotten AllowUsers, a firewall enabled before SSH was allowed, a Docker container publishing a port that ufw never sees. Gaia encodes that checklist in a verifiable way.
- 01Secure by defaultNo root login, no SSH passwords, inbound traffic denied.
- 02No lock-outsThe SSH configuration is validated with
sshd -tand checked withsshd -Tbefore it takes effect; if anything does not match, it is rolled back. The firewall allows SSH before it is enabled. - 03TransparentEvery action is a log line; secrets are masked;
--dry-runshows exactly what would change. - 04MeasurableLynis runs before and after and shows the hardening index gain. Listening ports are audited at the start and at the end, pointing out what is exposed to the internet.
- 05IdempotentRunning it again only fixes what drifted.
02What it does
Twenty steps, from preflight to summary.
- 01preflightroot, supported system, free disk, access to repositories, systemd; records what is listening (changes nothing)
- 02audit-beforebaseline Lynis audit (reference hardening index)
- 03packages
apt update,full-upgrade(configurable) and base packages - 04timetime zone and NTP synchronization
- 05hostnamehost name in
hostnamectl,/etc/hosts, preserved across cloud-init reboots - 06admin-useradministrator account in the
sudogroup, with SSH keys (literal, from GitHub or imported from the provider) - 07sshdrop-in with root and passwords off, modern crypto,
AllowUsers,MaxAuthTries,LoginGraceTime; validated with rollback - 08firewall
ufwdenying inbound, SSH rate-limited (limit) and allowed before enabling, extra rules - 09fail2ban
sshdjail on the configured port - 10auto-updates
unattended-upgradeswith security updates only; optional automatic reboot - 11sysctlanti-spoofing, no redirects, SYN cookies, restricted kernel information
- 12journaldpersistent, compressed journal with a disk cap
- 13apparmorAppArmor enabled and loading profiles
- 14swapoptional swap file for small VPS, with low swappiness
- 15servicesturns off network services a server rarely needs (rpcbind, avahi, cups) and keeps the local mail server on loopback
- 16directoriesdirectories with owner and mode (e.g.
/srv/apps) - +modulesoptional software, already hardened
- +custom stepsyour own scripts in
steps.d/ - 19audit-afterfinal Lynis audit, compared with the baseline
- 20summarywhat listens now, what was closed, and the next steps
03Before you run it
Four precautions before the first command.
- 01
Have a public SSH key for the administrator account. Gaia accepts any of these sources, in this order:
--ssh-key "ssh-ed25519 AAAA... you@laptop"(orGAIA_ADMIN_SSH_KEYSingaia.conf)--github-keys your-user(importshttps://github.com/your-user.keys)- the keys your VPS provider already placed in
/root/.ssh/authorized_keys(imported automatically when no other key was given)
- 02
Keep your current session open until you can log in with the new account from a second one.
- 03
Open in your provider’s firewall (security group, cloud firewall) the same ports you allow in Gaia, such as 80/443 for a website.
- 04
Run with
--dry-runfirst.
04Quick start
From the repository or with the release installer.
$ git clone https://github.com/Black-Ghost-Corp/Gaia-Bootstrapper.git$ cd Gaia-Bootstrapper# Interactive: asks for the administrator account and the modules.$ sudo ./bootstrap.sh# Non-interactive: everything on the command line.$ sudo ./bootstrap.sh --yes \ --admin-user alice \ --github-keys alice \ --modules docker,caddy \ --allow 80/tcp,443/tcp \ --hostname web-01.example.com \ --timezone America/Sao_Paulo \ --swap 2G$ curl -fsSL https://github.com/Black-Ghost-Corp/Gaia-Bootstrapper/releases/latest/download/install.sh | sudo bash# with options:$ curl -fsSL https://github.com/Black-Ghost-Corp/Gaia-Bootstrapper/releases/latest/download/install.sh \ | sudo bash -s -- --modules docker --admin-user alice --yesThe installer downloads the version and checks its SHA-256 (and its Ed25519 signature, when the release is signed) before running anything. The release lives in /opt/gaia/releases/<version> (linked from /opt/gaia/current), and an /opt/gaia/gaia.conf is used automatically when present.
Options
- --modules LIST
- optional modules, comma separated (e.g.
docker,caddy;noneorall) - --admin-user NAME
- administrator account (default: the user who ran sudo)
- --ssh-key KEY
- administrator public key (repeatable)
- --github-keys USER
- import keys from
https://github.com/USER.keys(repeatable) - --ssh-port PORT
- SSH port (default 22)
- --allow RULES
- extra inbound firewall rules (e.g.
80/tcp,443/tcp) - --hostname NAME
- host name
- --timezone TZ
- time zone (default UTC)
- --swap SIZE
- create a swap file (e.g.
2G) - --no-audit
- skip the Lynis audit
- --config FILE
- configuration file (default:
gaia.confnext tobootstrap.sh, if present) - --dry-run
- show what each step would change, without changing anything
- --only LIST
- run only these steps
- --skip LIST
- skip these steps
- --list-steps
- list the steps
- --yes, -y
- do not ask anything
05Modules
Software installed already configured securely.
Choose them with --modules, with GAIA_MODULES in gaia.conf or from the interactive menu.
- docker
What it installs
Docker Engine, compose and buildx from the official repository
Hardening applied
- GPG key checked by fingerprint
- log rotation and
live-restore - ports published by containers now obey
ufw(DOCKER-USERchain), opened only throughGAIA_DOCKER_PUBLISH - option to publish on
127.0.0.1only - warning that the
dockergroup is root-equivalent
- caddy
What it installs
Caddy (reverse proxy with automatic HTTPS) from the official repository
Hardening applied
- key checked
Caddyfilevalidated withcaddy validatebefore replacing it- HSTS,
nosniff,Referrer-Policy, noServerheader - internal paths blocked with 403
- reload without dropping connections
06Configuration
Everything is optional.
For repeated use (several identical machines), copy the example and adjust. Invalid values are rejected before any step runs.
Precedence
- command line
- gaia.conf
- environment variables
- defaults
$ cp gaia.conf.example gaia.conf$ chmod 600 gaia.conf$ sudo ./bootstrap.sh # picks up ./gaia.conf automatically07How it works
Validated before it takes effect. Logged after.
- Idempotent stepsEach step ends with a status:doneokskippedfailedwould changenot selected
- Files validated before they take effectCritical configuration (sshd, sudoers, fail2ban, ufw rules, Caddyfile) is written to a temporary file, validated by the tool itself and only then swapped in; if validation fails, the previous file stays.
- Third-party repositories verifiedGPG keys are downloaded over HTTPS and compared with the expected fingerprint before any
aptcall. - LogsOutput on screen and in
/var/log/gaia/gaia-<date>.log(mode 700), with secrets masked. A lock prevents two concurrent runs.[gaia][level][step=x] message key=value
08Custom steps
Your scripts, under the same contract.
Put executable scripts in steps.d/ (or in GAIA_EXTRA_STEPS_DIR). They run after the modules, receive the configuration and follow the same log, dry-run and status contract.
#!/usr/bin/env bash# gaia-description: creates the application’s docker networksource "$GAIA_LIB_DIR/common.sh"gaia_step_modedocker network inspect app >/dev/null 2>&1 || gaia_run docker network create app09Compatibility
Ubuntu and Debian, amd64 and arm64.
| System | Versions | Architectures |
|---|---|---|
| Ubuntu Server | 22.04 LTS, 24.04 LTS, 26.04 LTS | amd64, arm64 |
| Debian | 12 (bookworm), 13 (trixie) | amd64, arm64 |
Requires Bash 5, systemd and root access. Inside containers the kernel, swap and AppArmor steps are skipped (they belong to the host).
10Development and testing
Tested without touching the machine.
The unit tests run the whole of Gaia against a fake root (GAIA_ROOT) with system commands replaced by simulators.
$ scripts/test.sh # bats (unit tests against a fake system) + shellcheck$ scripts/test.sh integration # real run inside throwaway Ubuntu/Debian containers11Roadmap
Next steps.
In rough order of priority. Suggestions and PRs are welcome: open an issue to discuss before starting something big.
Short term
auditdwith baseline rules andAIDE(file integrity)--checkmode: only verifies compliance and exits non-zero on drift- Ready-made profiles (
--profile web,--profile docker-host,--profile bastion)
New modules
- Reverse proxies: hardened Nginx and Traefik
- Containers: Podman and rootless Docker; k3s with a CIS configuration
- Databases: PostgreSQL, MariaDB, Redis and MongoDB bound to loopback, with strong authentication and backups
- Private access: Tailscale and WireGuard (SSH over the VPN only)
- Active defense: CrowdSec as an alternative or complement to fail2ban
- Observability: node_exporter, Netdata and Uptime Kuma behind the proxy, no public ports
- Backups: restic or borg with scheduling and verification
- Runtimes: Node.js, Python and Go through version managers
- Isolated self-hosted CI runners
- Alerts (e-mail, Telegram, Slack) for logins, bans and pending updates
Platforms
- RHEL family (Rocky, AlmaLinux) with
firewalldand SELinux - Cloud images: ready-to-use cloud-init
user-datafor the main providers - Own download mirror as an alternative to GitHub
12Project
Contributing, security and license.
- Contributing
Code and logs are in English, every change comes with bats tests and passes
shellcheck, and nothing that changes the system may bypass--dry-run. - Security
Found a vulnerability? Do not open a public issue. Follow the security policy and use GitHub private reporting.
- License
Distributed under the Apache License 2.0.
Gaia changes the security configuration of your server. It is provided "as is", without warranties; review the --dry-run output and test on a throwaway machine before using it in production.

