This release adds major new features for SecuBox management and deployment: ## New Features ### 1. LuCI Admin Control Center (luci-app-secubox-admin) - Unified admin dashboard for managing all SecuBox appstore plugins - **Control Panel**: Real-time stats, system health, alerts, quick actions - **Apps Manager**: Browse catalog, install/remove apps with search & filtering - **App Settings**: Per-app configuration, start/stop controls - **System Health**: Live monitoring (CPU, RAM, disk) with auto-refresh - **System Logs**: Centralized log viewer with download capability - Fully integrated with existing RPCD backend (luci.secubox) - Mobile-responsive design with polished UI components ### 2. Documentation Mirror in SecuBox Bonus - Integrated complete development documentation into luci-app-secubox-bonus - 64+ documentation files now available offline at /luci-static/secubox/docs/ - Beautiful landing page (index-main.html) with 4 sections: - Development guides & references - Live module demos - Tutorials & blog posts - Marketing campaign pages - Accessible locally on router without internet connection ### 3. Automated Docker Plugin Installation - Enhanced secubox-appstore CLI with full Docker automation - One-click installation from web UI now fully automated: - Auto-detects Docker runtime from catalog - Discovers and executes control scripts (*ctl install) - Pulls Docker images automatically - Creates directories and configures UCI - Enables init services - No manual CLI steps required for Docker apps - Works for all Docker apps: AdGuard Home, Mail-in-a-Box, Nextcloud, etc. ### 4. Mail-in-a-Box Plugin - New Docker-based email server plugin (secubox-app-mailinabox) - Complete package with: - UCI configuration (8 port mappings, feature flags) - Control script (mailinaboxctl) with install/check/update/status/logs - Procd init script with auto-restart - Catalog manifest (category: hosting, maturity: beta) - Network mode: host (required for mail server) - Persistent storage: mail, SSL, data, DNS volumes ## Improvements ### Build System - Updated local-build.sh to include luci-app-* packages from package/secubox/ - Now automatically discovers and builds luci-app-secubox-admin and similar packages - Fixed Makefile include paths for feed structure ### Package Releases - Incremented PKG_RELEASE for all 31 SecuBox packages - Ensures clean upgrade path from previous versions ### Catalog Updates - Mail-in-a-Box entry moved from "productivity" to "hosting" category - Status changed to "beta" reflecting community Docker image maturity - Storage requirement increased: 1024MB → 2048MB - Added port 25 accessibility note ## Files Changed ### New Packages (2) - package/secubox/luci-app-secubox-admin/ (12 files) - package/secubox/secubox-app-mailinabox/ (4 files) ### Enhanced Packages (1) - package/secubox/luci-app-secubox-bonus/ (65 new docs files) ### Modified Core (3) - package/secubox/secubox-core/root/usr/sbin/secubox-appstore - package/secubox/secubox-core/root/usr/share/secubox/catalog.json - secubox-tools/local-build.sh ### All Makefiles (31 packages) - Incremented PKG_RELEASE for clean upgrade path ## Technical Details **Admin Control Center Architecture:** - Frontend: 5 views (dashboard, apps, settings, health, logs) - API: Wrapper around luci.secubox RPCD methods - Components: Reusable UI library (cards, badges, alerts, loaders) - Styling: Common + admin-specific CSS with responsive design - Auto-refresh: Polling for live updates (5-30s intervals) **Docker Automation Flow:** ``` Web UI → RPCD → secubox-appstore CLI → opkg install → *ctl install → docker pull → directories → UCI config → init enable → ✓ Ready ``` **Access Points:** - Admin Control: http://router/cgi-bin/luci/admin/secubox/admin/ - Documentation: http://router/luci-static/secubox/index-main.html - Demos: http://router/luci-static/secubox/demo-*.html 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> |
||
|---|---|---|
| .. | ||
| htdocs/luci-static/resources | ||
| root/usr | ||
| Makefile | ||
| README.md | ||
LuCI App - Key Storage Manager (KSM)
Version: 0.4.0
Last Updated: 2025-12-28
Status: Active
Centralized cryptographic key management system for OpenWrt with hardware security module (HSM) support for Nitrokey and YubiKey devices.
Overview
The Key Storage Manager provides a comprehensive solution for managing cryptographic keys, certificates, secrets, and SSH keys on OpenWrt. It supports both software-based key storage and hardware-backed cryptographic operations using USB security tokens.
Features
-
Cryptographic Key Management
- Generate RSA, ECDSA, and Ed25519 keys
- Import/export keys in PEM, DER, and PKCS#12 formats
- Secure deletion with shred support
- Key metadata tracking and organization
-
Hardware Security Module (HSM) Support
- Auto-detection of Nitrokey and YubiKey devices
- On-chip key generation
- PIN management and security
- Hardware-backed cryptographic operations
-
Certificate Management
- Generate Certificate Signing Requests (CSR)
- Import SSL/TLS certificates
- Certificate chain verification
- Expiration alerts (< 30 days)
-
Secrets Storage
- Encrypted storage for API keys, passwords, and tokens
- Categorized secret organization
- Automatic secret rotation (optional)
- Access audit logging
-
SSH Key Management
- Generate SSH key pairs (RSA, ECDSA, Ed25519)
- Deploy keys to remote hosts
- Support for SSH certificates
- Public key export and sharing
-
Audit Logging
- Comprehensive activity tracking
- Export logs to CSV format
- Filterable audit timeline
- User action accountability
Installation
Dependencies
The module requires the following packages:
luci-baserpcdopenssl-utilgnupg2nitropy(for Nitrokey support)yubikey-manager(for YubiKey support)opensc(smart card framework)libccid(USB CCID driver)pcscd(PC/SC daemon)
Install from Package
# Transfer package to router
scp luci-app-ksm-manager_*.ipk root@192.168.1.1:/tmp/
# Install on router
ssh root@192.168.1.1
opkg update
opkg install /tmp/luci-app-ksm-manager_*.ipk
# Restart services
/etc/init.d/rpcd restart
/etc/init.d/uhttpd restart
Build from Source
# In OpenWrt SDK
make package/luci-app-ksm-manager/compile V=s
make package/luci-app-ksm-manager/install
# Package will be in bin/packages/*/base/
Initial Setup
1. Install HSM Drivers (if using hardware tokens)
For Nitrokey devices:
opkg install nitropy python3-pip
For YubiKey devices:
opkg install yubikey-manager
2. Configure USB Permissions
Ensure your user has access to USB devices:
# Add udev rules for Nitrokey
cat > /etc/udev/rules.d/60-nitrokey.rules <<EOF
SUBSYSTEM=="usb", ATTR{idVendor}=="20a0", ATTR{idProduct}=="42b1", MODE="0660", GROUP="plugdev"
SUBSYSTEM=="usb", ATTR{idVendor}=="20a0", ATTR{idProduct}=="42b2", MODE="0660", GROUP="plugdev"
EOF
# Add udev rules for YubiKey
cat > /etc/udev/rules.d/70-yubikey.rules <<EOF
SUBSYSTEM=="usb", ATTR{idVendor}=="1050", MODE="0660", GROUP="plugdev"
EOF
# Reload udev rules
udevadm control --reload-rules
3. Initialize Keystore
Access the LuCI web interface:
- Navigate to Security → Key Storage Manager → Overview
- The keystore will be automatically initialized on first access
- Configure settings in Security → Key Storage Manager → Settings
Usage Guide
Managing Keys
Generate a New Key
- Go to Keys tab
- Select key type (RSA, ECDSA, or Ed25519)
- Choose key size (4096 bits recommended for RSA)
- Enter a label for identification
- Optionally set a passphrase for encryption
- Click Generate
Import Existing Key
- Go to Keys tab
- Scroll to Import Existing Key section
- Enter a label
- Select format (PEM, DER, or PKCS#12)
- Paste key data or upload file
- Enter passphrase if encrypted
- Click Import
Export Key
- Find the key in the table
- Click Export
- Select format and whether to include private key
- Click Export to download
Using Hardware Security Modules
Initialize HSM Device
- Connect Nitrokey or YubiKey via USB
- Go to HSM Devices tab
- Click Scan for Devices
- Select detected device
- Click Initialize
- Set Admin PIN (6-32 characters)
- Set User PIN (6-32 characters)
Important: Store PINs securely. Factory reset is required if forgotten.
Generate Key on HSM
- Go to HSM Devices tab
- Select initialized device
- Click Generate Key
- Choose key type and size
- Enter label
- Provide User PIN when prompted
Keys generated on-chip never leave the hardware device.
Certificate Management
Generate Certificate Signing Request (CSR)
- Go to Certificates tab
- Select an existing key or generate new one
- Enter Common Name (CN), e.g.,
example.com - Optionally add Organization, Country
- Click Generate
- Copy CSR and submit to Certificate Authority
Import Certificate
- After receiving signed certificate from CA
- Go to Certificates tab
- Select associated key
- Paste certificate data (PEM format)
- Optionally include certificate chain
- Click Import
Verify Certificate
- Find certificate in table
- Click Verify
- Check validity status, chain validation, and expiration
Managing Secrets
Store a Secret
- Go to Secrets tab
- Enter descriptive label (e.g., "GitHub API Key")
- Select category (API Key, Password, Token, etc.)
- Enter secret value
- Enable auto-rotation if desired
- Click Add
Retrieve Secret
- Find secret in table
- Click View
- Warning: Access is logged
- Copy secret to clipboard
- Secret auto-hides after 30 seconds
Rotate Secret
- Find secret in table
- Click Rotate
- Enter new secret value
- Confirm rotation
SSH Key Management
Generate SSH Key Pair
- Go to SSH Keys tab
- Enter label
- Select key type (Ed25519 recommended)
- Add optional comment
- Click Generate
- Copy public key for deployment
Deploy to Remote Host
- Select SSH key from list
- Click deploy section
- Enter target hostname/IP
- Enter target username
- Click Deploy
Alternatively, manually copy public key to ~/.ssh/authorized_keys on remote host.
Audit Logs
View Activity
- Go to Audit Logs tab
- Review chronological activity timeline
- Filter by date, user, action, or resource
- Logs auto-refresh every 15 seconds
Export Logs
- Click Export Logs (CSV)
- CSV file downloads with all audit entries
- Open in spreadsheet software for analysis
Settings
Configure Keystore
- Go to Settings tab
- Set keystore path (default:
/etc/ksm/keystore.db) - Configure auto-lock timeout
- Enable/disable auto-backup
- Set backup schedule (cron format)
Audit Settings
- Enable/disable audit logging
- Set retention period (default: 90 days)
- Choose log level (Info, Warning, Error)
Alert Settings
- Certificate expiration threshold (default: 30 days)
- Secret rotation reminders
- HSM disconnect alerts
Backup & Restore
Create Backup:
- Click Create Encrypted Backup
- Enter strong passphrase
- Confirm passphrase
- Download encrypted archive
Restore Backup:
- Click Restore from Backup
- Select backup file
- Enter backup passphrase
- Confirm restoration (overwrites existing data)
Security Best Practices
Key Management
- Use Strong Passphrases: Minimum 16 characters with mixed case, numbers, and symbols
- Key Size: Use 4096-bit RSA or Ed25519 for maximum security
- Secure Deletion: Always enable "secure erase" when deleting sensitive keys
- Regular Rotation: Rotate SSH keys and secrets every 90 days
- Hardware Storage: Use HSM for production keys when possible
HSM Usage
- PIN Complexity: Use different Admin and User PINs (minimum 8 characters)
- PIN Storage: Store PINs in password manager, not on device
- Backup Tokens: Keep backup HSM device for disaster recovery
- Physical Security: Secure HSM devices when not in use
- Retry Limits: HSM locks after failed PIN attempts - plan accordingly
Certificate Management
- Monitor Expiration: Enable alerts for certificates expiring < 30 days
- Verify Chains: Always verify certificate chain before deployment
- Renew Early: Renew certificates 2 weeks before expiration
- Revocation: Keep revocation procedures documented
- Intermediate CAs: Store intermediate certificates with end-entity certs
Secret Storage
- Access Logging: Review audit logs regularly for unauthorized access
- Least Privilege: Only grant secret access to necessary users
- Auto-Rotation: Enable for API keys and tokens
- Encryption: Secrets are encrypted with AES-256-GCM
- Backup Encryption: Always encrypt backups with strong passphrase
Troubleshooting
HSM Not Detected
Problem: Nitrokey or YubiKey not appearing in device list
Solutions:
- Check USB connection - try different port
- Verify drivers installed:
lsusbshould show device - Check permissions:
ls -la /dev/hidraw* - Restart pcscd:
/etc/init.d/pcscd restart - Check udev rules in
/etc/udev/rules.d/
Permission Denied Errors
Problem: Cannot access /dev/hidraw* or keystore files
Solutions:
- Add user to
plugdevgroup:usermod -a -G plugdev www-data - Check file permissions:
ls -la /etc/ksm/ - Verify RPCD runs as correct user
- Check ACL configuration in
/usr/share/rpcd/acl.d/
Keystore Locked
Problem: "Keystore locked" error when accessing keys
Solutions:
- Unlock via Settings → Keystore → Unlock
- Check auto-lock timeout setting
- Verify keystore file exists:
/etc/ksm/keystore.db - Check disk space:
df -h /etc/ksm
Certificate Verification Fails
Problem: Certificate chain validation errors
Solutions:
- Ensure intermediate certificates imported
- Check certificate order (end-entity → intermediate → root)
- Verify certificate hasn't expired
- Check system clock is correct:
date - Update CA bundle:
opkg update && opkg upgrade ca-bundle
Backup Restoration Fails
Problem: Cannot restore from backup
Solutions:
- Verify backup file integrity (check file size)
- Ensure correct passphrase
- Check available disk space
- Try backup on different system for testing
- Contact support if backup corrupt
API Reference
RPC Methods
The RPCD backend (luci.ksm-manager) provides 22 methods:
Status & Info:
status()- Get service statusget_info()- Get system information
HSM Management:
list_hsm_devices()- List connected HSM devicesget_hsm_status(serial)- Get HSM device statusinit_hsm(serial, admin_pin, user_pin)- Initialize HSMgenerate_hsm_key(serial, key_type, key_size, label)- Generate key on HSM
Key Management:
list_keys()- List all keysgenerate_key(type, size, label, passphrase)- Generate new keyimport_key(label, key_data, format, passphrase)- Import keyexport_key(id, format, include_private, passphrase)- Export keydelete_key(id, secure_erase)- Delete key
Certificate Management:
generate_csr(key_id, subject_dn, san_list)- Generate CSRimport_certificate(key_id, cert_data, chain)- Import certificatelist_certificates()- List certificatesverify_certificate(cert_id)- Verify certificate
Secret Management:
store_secret(label, secret_data, category, auto_rotate)- Store secretretrieve_secret(secret_id)- Retrieve secretlist_secrets()- List secretsrotate_secret(secret_id, new_secret_data)- Rotate secret
SSH Management:
generate_ssh_key(label, key_type, comment)- Generate SSH keydeploy_ssh_key(key_id, target_host, target_user)- Deploy SSH key
Audit:
get_audit_logs(limit, offset, filter_type)- Get audit logs
File Locations
- Keystore Database:
/etc/ksm/keystore.db - Configuration:
/etc/ksm/config.json - Keys:
/etc/ksm/keys/ - Certificates:
/etc/ksm/certs/ - Secrets:
/etc/ksm/secrets/ - Audit Log:
/var/log/ksm-audit.log - RPCD Backend:
/usr/libexec/rpcd/luci.ksm-manager
Development
Project Structure
luci-app-ksm-manager/
├── Makefile
├── README.md
├── htdocs/luci-static/resources/
│ ├── view/ksm-manager/
│ │ ├── overview.js
│ │ ├── keys.js
│ │ ├── hsm.js
│ │ ├── certificates.js
│ │ ├── secrets.js
│ │ ├── ssh.js
│ │ ├── audit.js
│ │ └── settings.js
│ └── ksm-manager/
│ └── api.js
└── root/
└── usr/
├── libexec/rpcd/
│ └── luci.ksm-manager
└── share/
├── luci/menu.d/
│ └── luci-app-ksm-manager.json
└── rpcd/acl.d/
└── luci-app-ksm-manager.json
Running Tests
# Validate shell scripts
shellcheck root/usr/libexec/rpcd/luci.ksm-manager
# Validate JSON files
jsonlint root/usr/share/luci/menu.d/luci-app-ksm-manager.json
jsonlint root/usr/share/rpcd/acl.d/luci-app-ksm-manager.json
# Test RPCD methods
ubus call luci.ksm-manager status
ubus call luci.ksm-manager list_keys
Contributing
Contributions are welcome! Please:
- Follow OpenWrt coding standards
- Test on actual hardware before submitting
- Update documentation for new features
- Include validation tests
License
Copyright (C) 2025 SecuBox Project
Licensed under the Apache License, Version 2.0
Support
- Issues: GitHub Issues
- Documentation: SecuBox Wiki
- Forum: OpenWrt Forum - SecuBox
Changelog
Version 1.0.0 (2025-01-XX)
- Initial release
- Full HSM support (Nitrokey, YubiKey)
- Cryptographic key management
- Certificate management with CSR generation
- Encrypted secrets storage
- SSH key management and deployment
- Comprehensive audit logging
- Backup and restore functionality