Prerequisites
- A GCP account with a project
- A service account with Compute Engine permissions
- A service account key file (JSON)
- An SSH key pair (local
~/.ssh/id_rsaand~/.ssh/id_rsa.pub)
Required IAM Permissions
The service account needs these roles (or use theCompute Admin role):
roles/compute.admin) role to your service account.
Create a Service Account and Key
- Go to IAM & Admin > Service Accounts > Create Service Account
- Name it
osmedeus-cloud(or similar) - Grant it the Compute Admin role
- Go to the service account > Keys > Add Key > Create new key > JSON
- Save the JSON file (e.g.,
~/.gcp/osmedeus-sa.json)
gcloud CLI:
Configuration
Minimal Setup
Machine Types
Preemptible Instances
Preemptible VMs cost up to 80% less than on-demand. They last at most 24 hours and can be reclaimed, but are ideal for security scanning workloads.Regions and Zones
Pick a region close to your targets or with the lowest pricing:Note: The zone must be within the selected region.
Custom Image Family
Use a custom image family with tools pre-installed for faster startup:Cost Limits
Examples
Quick Domain Recon
Large-Scale Subdomain Enumeration
Custom Nmap Scan
Distributed Nuclei Scanning
Preemptible Instance Pipeline
Persistent Recon Campaign
Multi-Region Scanning
Troubleshooting
”Permission denied” or “403 Forbidden”
Your service account lacks required permissions. Assign the Compute Admin role:“Credentials file not found”
Make sure the JSON key file path is correct and the file exists:Instances Not Starting
”Compute Engine API has not been used” Error
Enable the Compute Engine API for your project:SSH Connection Timeout
Preemptible Instance Terminated
Preemptible VMs are reclaimed after 24 hours or when GCP needs capacity. The scan will fail for that worker. Mitigation:- Use
--auto-destroyto clean up - Re-run the failed targets
- Use on-demand instances for critical or long-running scans
Cleaning Up
Cost Optimization
- Use preemptible instances for all non-critical scans (
use_preemptible: true) — up to 80% savings - Right-size machines: e2-medium is enough for most single-target scans
- Always use
--auto-destroyto prevent forgotten instances - Set cost limits to catch runaway spending
- Use custom images to reduce setup time (less instance-hours)
- Pick the cheapest region if target geo-location doesn’t matter (us-central1 is usually cheapest)
- GCP sustained-use discounts apply automatically for on-demand VMs running more than 25% of the month
