Skip to content

Conversation

@imlk0
Copy link
Collaborator

@imlk0 imlk0 commented Dec 25, 2025

This commit introduces cryptpilot-enhance.sh, a new utility that securely hardens offline VM disk images (e.g., QCOW2) before encryption. The script uses virt-customize to apply system-level security configurations in a single guest launch, minimizing performance overhead and ensuring compatibility with secure or containerized build environments.

Key features:

  • Supports two hardening modes: 'full' (maximum security, removes SSH) and 'partial' (retains SSH with key-only access)
  • Removes cloud-specific agents (Aliyun Cloud Assistant, Aegis/Security Center) and unneeded services (rpcbind, cloud-init)
  • Locks root/admin passwords and cleans up non-essential user accounts and sensitive data (e.g., .DEL dirs, shell history)
  • Hardens SSH configuration in partial mode (disables password login, X11/TCP forwarding)
  • Optionally injects SSH public keys for authorized root login
  • Includes support for direct libguestfs backend (LIBGUESTFS_BACKEND=direct), ideal for CI/containers

The following files are added:

  • cryptpilot-enhance.sh: Main executable script with comprehensive logging and error handling
  • docs/cryptpilot_enhance.md: Detailed documentation in English
  • docs/cryptpilot_enhance_zh.md: Corresponding documentation in Chinese
  • Updated cryptpilot.spec to include the new binary in package installation

The tool is designed for use in secure pipelines where minimal attack surface and audit compliance are required. Users are advised to test on image copies due to irreversible modifications.

This commit introduces `cryptpilot-enhance.sh`, a new utility that securely hardens offline VM disk images (e.g., QCOW2) before encryption. The script uses `virt-customize` to apply system-level security configurations in a single guest launch, minimizing performance overhead and ensuring compatibility with secure or containerized build environments.

Key features:
- Supports two hardening modes: 'full' (maximum security, removes SSH) and 'partial' (retains SSH with key-only access)
- Removes cloud-specific agents (Aliyun Cloud Assistant, Aegis/Security Center) and unneeded services (rpcbind, cloud-init)
- Locks root/admin passwords and cleans up non-essential user accounts and sensitive data (e.g., .DEL dirs, shell history)
- Hardens SSH configuration in partial mode (disables password login, X11/TCP forwarding)
- Optionally injects SSH public keys for authorized root login
- Includes support for direct libguestfs backend (LIBGUESTFS_BACKEND=direct), ideal for CI/containers

The following files are added:
- `cryptpilot-enhance.sh`: Main executable script with comprehensive logging and error handling
- `docs/cryptpilot_enhance.md`: Detailed documentation in English
- `docs/cryptpilot_enhance_zh.md`: Corresponding documentation in Chinese
- Updated `cryptpilot.spec` to include the new binary in package installation

The tool is designed for use in secure pipelines where minimal attack surface and audit compliance are required. Users are advised to test on image copies due to irreversible modifications.

Signed-off-by: Kun Lai <laikun@linux.alibaba.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants