Skip to main content

Debian Sid Sandbox — instant QEMU/KVM VM from cloud images

Project description

debsb

Debian Sid sandbox in one command. Downloads a Debian cloud image, boots it in QEMU/KVM, and gives you an isolated VM with auto-login, SSH, and shared filesystem. No kernel building, no complex setup.

debsb tutorial

Motivation

I just want a fully hackable Debian setup—both user space and kernel—within a restricted sandbox.

I want to avoid rebuilding an OpenSSH-enabled rootfs for each fuzzing test and repeatedly using the -kernel and -initrd flags in QEMU.

Install

pip install debsb

Dependencies

  • qemu-system-x86_64 (with KVM support)
  • cloud-image-utils (cloud-localds)
  • whois (mkpasswd)
  • wget
  • ssh

On Debian/Ubuntu:

sudo apt install qemu-system-x86 cloud-image-utils whois wget openssh-client

For --debian kernel builds, additionally:

sudo apt install python3-dacite python3-debian python3-jinja2 debhelper quilt rsync devscripts dh-python

Usage

Build the sandbox (one-time)

debsb build --size 20G

This downloads the Debian Sid cloud image, configures SSH keys and auto-login, and runs first boot. All artifacts are stored in ~/.debsb/.

Use --reset to skip the prompt and rebuild from scratch:

debsb build --size 20G --reset

Build with a custom kernel (upstream)

debsb build ~/linux --configitem CONFIG_KASAN=y --configitem CONFIG_KCOV=y

This:

  1. Sets up the cloud image (if not already done)
  2. Generates a default kernel config (make defconfig) with VM-essential options
  3. Applies --configitem entries
  4. Runs make olddefconfig and make bindeb-pkg
  5. Installs the resulting .deb into the VM via GRUB

Build with Debian kernel

This kernel image is built based on the official Debian repository.

# Default branch (debian/latest)
debsb build --debian --configitem CONFIG_KASAN=y --configitem CONFIG_KCOV=y

# Specific branch
debsb build --debian --branch debian/sid

This clones the Debian kernel from salsa.debian.org/kernel-team/linux.git, applies config items to debian/config/config, and builds the amd64 kernel package using the Debian packaging rules. The resulting kernel is installed into the VM via GRUB.

Run the sandbox

# Serial console (auto-login as debian, Ctrl-A X to quit)
debsb run

# SSH session (as debian)
debsb run --ssh

# SSH as root
debsb run --ssh --root

# Run a command and auto-shutdown (requires --ssh)
debsb run --ssh --root --exec "apt update && apt upgrade -y"

# Graphical QEMU window
debsb run --graphics

# With sound
debsb run --sound

# Extra QEMU options
debsb run --qemu-opts='-m 8192'

Execute a command

--exec runs a command via SSH and shuts down automatically. Requires --ssh:

debsb run --ssh --exec "uname -a"
debsb run --ssh --root --exec "ls -ahl .debsb"
debsb run --ssh --exec "./my-script.sh"

This is useful for CI/automation. The exit code of the command is propagated.

Verbose mode

Show kernel boot messages:

debsb run --verbose

Shared filesystem

Your host ~/.debsb/ directory is mounted inside the VM at:

  • /root/.debsb (symlink to /mnt/debsb)
  • /home/debian/.debsb (symlink to /mnt/debsb)

This is automatic — no manual mounting needed.

How it works

  1. Downloads debian-sid-generic-amd64-daily.qcow2 from cloud.debian.org
  2. Creates a cloud-init ISO with SSH keys, user config, and auto-login
  3. Boots the VM with QEMU/KVM and waits for cloud-init to finish
  4. On subsequent debsb run, boots the prepared image directly

When building with a kernel (debsb build <path> or debsb build --debian):

  • The kernel .deb is installed into the VM
  • GRUB is updated to boot the new kernel by default
  • No -kernel or -initrd flags needed — GRUB handles boot

Accounts

User Access
debian Serial auto-login, SSH with key, sudo NOPASSWD
root SSH with key (--root flag)

SSH key: ~/.debsb/id_ed25519 (auto-generated on first build)

License

GPL-2.0-only

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

debsb-0.2.1.tar.gz (24.3 kB view details)

Uploaded Source

Built Distribution

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

debsb-0.2.1-py3-none-any.whl (23.4 kB view details)

Uploaded Python 3

File details

Details for the file debsb-0.2.1.tar.gz.

File metadata

  • Download URL: debsb-0.2.1.tar.gz
  • Upload date:
  • Size: 24.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for debsb-0.2.1.tar.gz
Algorithm Hash digest
SHA256 089bb5f6e08170004a6699d16fe17e3c47db04455d1e3d9629135f834625aadc
MD5 78004aec623fb7968eb78ffc2a5a81b0
BLAKE2b-256 7145380ea4149897f966ad9bfd0585f6fb392266df12814785d4ca7e9aaf3f83

See more details on using hashes here.

File details

Details for the file debsb-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: debsb-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 23.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for debsb-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8276adab9262ad9cbe331f5abc9831322b8457ae3c589ffee8ca0848fd2b30dd
MD5 45d4ee8a6900cd8cad1d139d5b791768
BLAKE2b-256 0cd4f44e8420e0f5d7c3b19095c679b3fd57b1f51ad3293c33f4a9e032044b4a

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