Skip to content

Ubuntu Bootstrap System - Complete system configuration backup and restoration with military-grade encryption

Notifications You must be signed in to change notification settings

mcollard0/bootstrap

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

11 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Ubuntu Bootstrap System

Complete system configuration backup and restoration for Ubuntu systems with military-grade encryption.

⚠️ Public Repository Notice: This is a template/example repository. Before using:

  1. Fork or clone this repository to your own account
  2. Set up your own encrypted secrets (see SECRETS_SETUP.md)
  3. Never commit real API keys or passwords to version control

This is what I wanted NIX to be...

πŸš€ Overview

The Ubuntu Bootstrap System is a comprehensive solution for capturing, encrypting, and restoring complete Ubuntu system configurations. It creates an encrypted inventory of your entire system setup and generates restoration scripts that can recreate your exact environment on a fresh Ubuntu installation.

πŸ” Key Security Features

  • ChaCha20-Poly1305 encryption for sensitive data (used by Signal, WireGuard)
  • Argon2id key derivation (memory-hard, side-channel resistant)
  • No plaintext secrets ever stored in version control
  • Inline decryption during system restoration
  • Automated backup rotation with secure deletion

πŸ“Š System Coverage

  • 2,556+ APT packages with version pinning
  • 14 Snap packages with channel tracking
  • 108+ Python modules with exact versions
  • SSH keys and configurations with permission preservation
  • Environment variables with encrypted sensitive values
  • System configurations (sysctl, cron jobs, .bashrc customizations)

✨ Features

πŸ›‘οΈ Special Security Configurations

  • Intel KVM Module Disabling: Creates blacklist configuration and unloads virtualization modules
  • Firefox Removal: Automatically removes Firefox (both snap and APT versions)
  • Flatpak Installation: Installs flatpak package manager and configures Flathub repository

πŸ”§ Smart Package Handling

  • Pre-installation checks: Skip packages that are already installed
  • Batch installations: Efficient package installation in groups
  • Special packages: Custom handling for Chrome, Docker, VirtualBox, Warp Terminal
  • System packages: Intelligent filtering of system-only packages

πŸ• Automation

  • Weekly cron scheduling: Automatic inventory updates every Monday at 3 AM
  • Git integration: Automated commits and pushes with SSH support
  • Backup rotation: 50 backups for small files (<150KB), 25 for large files (β‰₯150KB)

πŸ“ Project Structure

bootstrap/
β”œβ”€β”€ src/                    # Python source code
β”‚   β”œβ”€β”€ crypto_utils.py     # ChaCha20-Poly1305 + Argon2id encryption
β”‚   β”œβ”€β”€ bootstrap_scanner.py # System inventory scanner
β”‚   β”œβ”€β”€ generate_bootstrap.py # Bootstrap script generator
β”‚   └── make_backup.py      # Backup management with rotation
β”œβ”€β”€ scripts/                # Generated and automation scripts
β”‚   β”œβ”€β”€ bootstrap.sh        # Main restoration script
β”‚   β”œβ”€β”€ git_auto_push.sh    # Automated git operations
β”‚   └── setup_cron.sh       # Cron job management
β”œβ”€β”€ docs/                   # Documentation
β”‚   β”œβ”€β”€ architecture.md     # System architecture details
β”‚   β”œβ”€β”€ CONTRIBUTING.md     # Development guidelines
β”‚   └── TESTING.md         # VM testing procedures
β”œβ”€β”€ data/                   # System inventory and encrypted data
β”‚   β”œβ”€β”€ inventory.json      # System state snapshot
β”‚   └── encrypted_secrets.json # Encrypted sensitive data
β”œβ”€β”€ backup/                 # Automated dated backups
└── .git/                   # Version control

πŸš€ Quick Start

1. Initial System Scan

cd /path/to/bootstrap
python3 src/bootstrap_scanner.py

Creates encrypted inventory of your current system (prompts for master password)

2. Generate Bootstrap Script

python3 src/generate_bootstrap.py

Creates scripts/bootstrap.sh with restoration commands

3. Setup Automation

./scripts/setup_cron.sh install

Installs weekly cron job for automatic updates

4. Test on Fresh System

sudo ./scripts/bootstrap.sh

Restores complete system configuration (prompts for master password)

πŸ§ͺ Testing

Complete VM testing setup included:

# Creates Ubuntu 24.04.3 VM for testing
VBoxManage createvm --name "Ubuntu-Bootstrap-Test" --ostype "Ubuntu_64" --register

# Comprehensive test verification
# See docs/TESTING.md for complete procedures

Test Results Expected

  • βœ… Firefox completely removed
  • βœ… Chrome, Docker, VirtualBox installed
  • βœ… Flatpak configured with Flathub
  • βœ… Intel KVM modules disabled
  • βœ… 100+ Python packages restored
  • βœ… All encrypted secrets decrypted
  • βœ… SSH keys and cron jobs restored

πŸ”’ Security Model

Encryption Specifications

  • Algorithm: ChaCha20-Poly1305 (AEAD cipher)
  • Key Size: 256-bit keys, 96-bit nonces, 128-bit authentication tags
  • KDF: Argon2id with 64MB memory, 3 iterations, 4 parallelism
  • No Key Storage: Master password required for each decryption

Threat Model Protection

  • βœ… Data at Rest: All sensitive data encrypted in git repository
  • βœ… Memory Safety: Keys cleared immediately after use
  • βœ… Side Channels: Argon2id provides resistance to timing attacks
  • βœ… Brute Force: Memory-hard KDF makes password cracking expensive
  • βœ… Tampering: Poly1305 MAC prevents modification attacks

What's Protected

  • API keys (OpenAI, Anthropic, XAI, Google Places, etc.)
  • Database connection strings (MongoDB URIs, PostgreSQL, etc.)
  • Email passwords and SMTP credentials
  • Custom environment variables containing secrets
  • Any sensitive configuration you choose to encrypt

πŸ“‹ System Requirements

Host System

  • Ubuntu 25.04 (Plucky) - Primary target
  • Ubuntu 24.04 - Tested and supported
  • Python 3.13+ with cryptography and argon2-cffi
  • Git with SSH key configuration
  • sudo privileges for system-level operations

Target System (Restoration)

  • Fresh Ubuntu installation (24.04+ recommended)
  • Internet connectivity for package downloads
  • 4GB+ RAM (for large package installations)
  • 20GB+ free disk space

πŸ› οΈ Advanced Usage

Manual Backup Creation

python3 src/make_backup.py

Cron Job Management

./scripts/setup_cron.sh status    # Check current status
./scripts/setup_cron.sh remove    # Remove cron jobs
./scripts/setup_cron.sh install   # Install weekly job

Git Repository Setup

# Fork this repository or create your own
git clone https://github.com/mcollard0/bootstrap.git
cd bootstrap

# Set up your own remote (recommended: private repository)
git remote set-url origin git@github.com:YOUR_USERNAME/your-bootstrap.git
git push -u origin main

Setting Up Your Secrets

# Copy example secrets and encrypt your own data
cp data/encrypted_secrets.example.json data/encrypted_secrets.json

# Use the interactive encryption tool
python3 src/crypto_utils.py

# Or see SECRETS_SETUP.md for detailed instructions

Custom Configuration

Edit src/bootstrap_scanner.py to modify:

  • Package filtering rules
  • Sensitive data detection patterns
  • System configuration scanning

πŸ”§ Architecture

Core Components

  1. System Scanner (bootstrap_scanner.py)

    • Inventories all installed packages and configurations
    • Detects sensitive data using regex patterns
    • Encrypts secrets with ChaCha20-Poly1305
  2. Script Generator (generate_bootstrap.py)

    • Creates idempotent bash restoration script
    • Handles special packages and configurations
    • Embeds encrypted secrets with inline decryption
  3. Backup Manager (make_backup.py)

    • Creates dated backups: filename.YYYYMMDD.ext
    • Automatic rotation based on file size
    • LRU deletion for cleanup
  4. Automation Scripts

    • Weekly cron job scheduling
    • Automated git operations with SSH
    • Comprehensive VM testing framework

Data Flow

Current System β†’ Scanner β†’ Encrypted Inventory β†’ Generator β†’ Bootstrap Script β†’ Fresh System
     ↑                                                                              ↓
 Cron Updates ← Git Push ← Backup Creation ← Weekly Schedule         Master Password Prompt

🀝 Contributing

Please read CONTRIBUTING.md for:

  • Code style guidelines (spaces in function calls, semicolons, long lines)
  • Security practices and backup procedures
  • Development workflow and testing requirements
  • Architecture compliance rules

πŸ“„ License

This project is intended for personal system administration use. Review and understand the code before running on production systems.

πŸ†˜ Support

Common Issues

  • Decryption fails: Verify master password matches original
  • Package conflicts: Check Ubuntu version compatibility
  • Permission errors: Ensure sudo access for system operations
  • Network timeouts: Verify internet connectivity during restoration

Debug Mode

# Enable verbose logging
export BOOTSTRAP_DEBUG=1
sudo ./scripts/bootstrap.sh

Documentation


Created: September 2025
Version: 1.0
Ubuntu Support: 24.04+, 25.04 (Plucky)
Security: ChaCha20-Poly1305 + Argon2id
Status: Production Ready βœ…

About

Ubuntu Bootstrap System - Complete system configuration backup and restoration with military-grade encryption

Resources

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published