← All Scanning Guides
Prerequisites
1

Enable the guest agent and prepare directories

Proxmox Host
VMID=100
VG_DIR=/opt/versiongopher
OUT_DIR=/var/tmp/versiongopher

qm start "$VMID"
qm set "$VMID" --agent 1

# Create working directories inside the guest
qm guest exec "$VMID" -- /bin/sh -lc \
  "mkdir -p '$VG_DIR' '$OUT_DIR'"
2

Inject the collector via stdin

For small payloads (<1 MiB), base64-encode the collector and pipe it through the guest agent.
Proxmox Host
# Create a payload tarball
tar czf /tmp/vg-payload.tgz version_gopher

# Inject via base64 over guest agent stdin
base64 -w0 /tmp/vg-payload.tgz | \
  qm guest exec "$VMID" --pass-stdin 1 -- /bin/sh -lc '
    base64 -d > /tmp/vg-payload.tgz &&
    tar xzf /tmp/vg-payload.tgz -C /opt/versiongopher &&
    chmod +x /opt/versiongopher/version_gopher
  '
⚠️ Size limit: qm guest exec --pass-stdin supports a maximum of ~1 MiB. For larger payloads, pre-bake the collector into the VM template, use SSH/SCP, or use virt-customize on a stopped image.
3

Run the scan

Proxmox Host
qm guest exec "$VMID" --timeout 0 -- /bin/sh -lc \
  "cd /opt/versiongopher && \
   ./version_gopher /usr/bin -o '$OUT_DIR/scan'"
Tip: Use --timeout 0 for long-running scans to prevent the guest agent from timing out.
4

Retrieve results

qm guest exec returns JSON with out-data, err-data, and exitcode fields. Use jq to extract stdout.
Proxmox Host
qm guest exec "$VMID" -- /bin/sh -lc \
  "cat '$OUT_DIR/scan.json'" \
  | jq -r '."out-data"' > "/tmp/vm-${VMID}-scan.json"