Files
osmedeus/docs/cloud/cloud-cheatsheet.md
T
j3ssie 0269cf4e26 feat: update Next.js build assets and add cloud setup E2E tests
- Update Next.js generated chunk hashes and build IDs reflecting latest dashboard build
- Update CSS stylesheet references in workflow upload page metadata
- Add comprehensive cloud setup E2E test suite (cloud_setup_test.go) with SSH password/key auth, post-command variable expansion, and Ansible integration
- Fix API priority levels to include 'medium' priority in test coverage
- Add agent-sdk test workflows (minimal, config, codex, multi-agent, session variants)
- Update E2E test utilities with runCLIInBase helper for multi-step cloud config tests
- Fix stderr/stdout capture in dependencies_target_types_test assertions
2026-04-04 13:57:34 +08:00

162 lines
5.8 KiB
Markdown

# Cloud Cheatsheet
## First-Time Setup
```bash
# 0. Enable cloud feature
osmedeus config set cloud.enabled true
# 1. Credentials (pick one provider)
osmedeus cloud config set providers.aws.access_key_id <key>
osmedeus cloud config set providers.aws.secret_access_key <secret>
osmedeus cloud config set providers.aws.region ap-southeast-1
osmedeus cloud config set defaults.provider aws
# 2. SSH
osmedeus cloud config set ssh.private_key_path ~/.ssh/id_rsa
osmedeus cloud config set ssh.public_key_path ~/.ssh/id_rsa.pub
# 3. Clean the setup scripts first, then add worker setup
osmedeus cloud config set setup.commands.clear ""
osmedeus cloud config set setup.commands.add "curl -fsSL https://www.osmedeus.org/install.sh | bash"
osmedeus cloud config set setup.commands.add "osmedeus install base --preset"
# 4. Cost limits (recommended)
osmedeus cloud config set limits.max_hourly_spend 1.00
osmedeus cloud config set limits.max_total_spend 10.00
```
## Workflow Mode
```bash
osmedeus cloud run -f fast -t example.com # Single target
osmedeus cloud run -f fast -T targets.txt --instances 5 # Distributed
osmedeus cloud run -f fast -t example.com --sync-back # Sync results
osmedeus cloud run -f fast -t example.com --auto-destroy # Auto cleanup
osmedeus cloud run -f fast -t example.com --sync-back --auto-destroy # Full lifecycle
osmedeus cloud run -f fast -t example.com --reuse # Reuse infra
osmedeus cloud run -m enum-subdomain -t example.com --timeout 30m # Module + timeout
```
## Custom Command Mode
```bash
# Run anything on cloud instances
osmedeus cloud run --custom-cmd "nmap -sV {{Target}}" -t example.com
# Pipeline: multiple commands, sync results
osmedeus cloud run \
--custom-cmd "subfinder -d {{Target}} -o /tmp/osm-custom/subs.txt" \
--custom-cmd "cat /tmp/osm-custom/subs.txt | httpx -o /tmp/osm-custom/live.txt" \
--custom-post-cmd "wc -l /tmp/osm-custom/live.txt" \
--sync-path "/tmp/osm-custom/" \
-t example.com --auto-destroy
# Distribute targets, sync to custom dir
osmedeus cloud run \
--custom-cmd "cat {{Target}} | nuclei -o /tmp/osm-custom/nuclei.txt" \
--sync-path "/tmp/osm-custom/nuclei.txt" \
--sync-dest "./nuclei-results" \
-T targets.txt --instances 5
```
### Variables: `{{Target}}` `{{public_ip}}` `{{private_ip}}` `{{worker_name}}` `{{worker_id}}` `{{infra_id}}` `{{provider}}` `{{ssh_user}}` `{{index}}`
### Rules
- Commands run in `/tmp/osm-custom/` on remote
- Sequential per worker, parallel across workers
- First failure skips remaining cmds + post-cmds
- Sync destination: `<sync-dest>/<worker_name>-<ip>/<path>`
## Infrastructure
```bash
osmedeus cloud create --provider aws -n 3 # Create
osmedeus cloud list # List
osmedeus cloud destroy <id> # Destroy one
osmedeus cloud destroy all --force # Destroy all
osmedeus cloud setup --reuse-with "1.2.3.4" # Setup existing
```
## Config
```bash
osmedeus cloud config list # View
osmedeus cloud config set <key> <value> # Set
osmedeus cloud config set <key>.add <value> # Append to list
osmedeus cloud config clean # Reset
```
## Provider Quick Config
**AWS:**
```bash
osmedeus cloud config set providers.aws.access_key_id ${AWS_ACCESS_KEY_ID}
osmedeus cloud config set providers.aws.secret_access_key ${AWS_SECRET_ACCESS_KEY}
osmedeus cloud config set providers.aws.region ap-southeast-1
osmedeus cloud config set providers.aws.instance_type t3.medium
osmedeus cloud config set providers.aws.use_spot true # 70% cheaper
```
**Hetzner:**
```bash
osmedeus cloud config set providers.hetzner.token ${HETZNER_API_TOKEN}
osmedeus cloud config set providers.hetzner.location fsn1
osmedeus cloud config set providers.hetzner.server_type cx22
```
**DigitalOcean:**
```bash
osmedeus cloud config set providers.digitalocean.token ${DO_TOKEN}
osmedeus cloud config set providers.digitalocean.region sgp1
osmedeus cloud config set providers.digitalocean.size s-2vcpu-4gb
```
**GCP:**
```bash
osmedeus cloud config set providers.gcp.project_id ${GCP_PROJECT}
osmedeus cloud config set providers.gcp.credentials_file /path/to/sa-key.json
osmedeus cloud config set providers.gcp.region us-central1
osmedeus cloud config set providers.gcp.zone us-central1-a
osmedeus cloud config set providers.gcp.machine_type n1-standard-2
```
**Linode:**
```bash
osmedeus cloud config set providers.linode.token ${LINODE_TOKEN}
osmedeus cloud config set providers.linode.region ap-south
osmedeus cloud config set providers.linode.type g6-standard-2
```
**Azure:**
```bash
osmedeus cloud config set providers.azure.subscription_id ${AZURE_SUB_ID}
osmedeus cloud config set providers.azure.tenant_id ${AZURE_TENANT_ID}
osmedeus cloud config set providers.azure.client_id ${AZURE_CLIENT_ID}
osmedeus cloud config set providers.azure.client_secret ${AZURE_CLIENT_SECRET}
osmedeus cloud config set providers.azure.location southeastasia
osmedeus cloud config set providers.azure.vm_size Standard_B2s
```
## Cost Reference
| Provider | Instance | vCPU | RAM | $/hr |
|----------|----------|------|-----|------|
| Hetzner | cx22 | 2 | 4 GB | 0.007 |
| Linode | g6-standard-2 | 2 | 4 GB | 0.018 |
| DigitalOcean | s-2vcpu-4gb | 2 | 4 GB | 0.022 |
| AWS | t3.medium | 2 | 4 GB | 0.042 |
| Azure | Standard_B2s | 2 | 4 GB | 0.042 |
| GCP | n1-standard-2 | 2 | 7.5 GB | 0.095 |
5 x Hetzner cx22 x 2 hours = **$0.07** | 5 x DO s-2vcpu-4gb x 2 hours = **$0.22**
## Troubleshooting
```bash
osmedeus cloud run -f fast -t example.com --verbose-setup # See setup output
osmedeus cloud run -f fast -t example.com --debug # Full debug logs
osmedeus cloud list # Check for orphans
osmedeus cloud destroy all --force # Emergency cleanup
```