Skip to Content
IntegrationsServers and EndpointsDeployment Automation

Secrets Management

Learn how you can use secrets managers such as HashiCorp Vault, Google Cloud Secret Manager, and AWS Secrets Manager with Mondoo.

To facilitate SSH scanning of a fleet of instances, Mondoo integrates with several vault systems:

  • AWS Secrets Manager (aws-secrets-manager)
  • AWS SSM Parameter Store (aws-parameter-store)
  • Google Cloud Secret Manager (gcp-secret-manager)
  • GCP Berglas (gcp-berglas)
  • HashiCorp Vault (hashicorp-vault)
  • The operating system's keyring (keyring), such as macOS Keychain, the Windows credential store, or on Linux, the Secret Service (such as GNOME Keyring) or KWallet
  • The Linux kernel keyring (linux-kernel-keyring), for headless Linux servers that don't run a Secret Service
  • Encrypted file (encrypted-file)

The value in parentheses is the vault's type.

Each vault is configured in your inventory file's spec.vault block, and assets reference its secrets by secret_id. For the full schema and every vault type's options, read Vault integration in the inventory file reference.

HashiCorp Vault

Create a vault secret:

vault kv put secret/vcenter/mondoo-read password="< password >" type="password" user="mondoo-read@vsphere.local"

Reference it from your inventory file's spec.vault:

inventory.yml
spec:
  assets:
    - name: vsphere-env
      connections:
        - type: vsphere
          host: < ip of the ESXi or vCenter >
          insecure: true
          credentials:
            - secret_id: vcenter/mondoo-read
  vault:
    name: cnspec-hashivault
    type: hashicorp-vault
    options:
      url: < Url to vault >
      token: < Token >

cnspec reads each secret_id from a KV version 2 secrets engine at <mount>/data/<secret_id>. The mount option defaults to secret, the path that the vault kv put command above writes to. If your KV version 2 engine is mounted at another path, add mount: <path> under options.

Encrypted file

Configure cnspec's vault to use an encrypted file for secrets, and store the configuration in your existing inventory file:

sudo cnspec vault configure mondoo-client-vault --type encrypted-file --option=password='changeme' --option path='/etc/opt/mondoo/vault.enc' --inventory-file /etc/opt/mondoo/inventory.yml

With --inventory-file, cnspec writes the vault configuration to the inventory file's spec.vault block, replacing any vault configured there. Without it, cnspec stores nothing: it only prints a spec.vault block, which you must add to your inventory file yourself before you add secrets.

Then add a secret to it:

sudo cnspec vault add-secret vcenter '{ "type": "password", "user": "chris@vsphere.local", "password": "password" }' --inventory-file /etc/opt/mondoo/inventory.yml

cnspec vault add-secret requires --inventory-file, because it reads the vault configuration from the inventory file's spec.vault block. If the block is missing, the command fails with could not load vault configuration from inventory.

cnspec doesn't keep its own list of vaults, so cnspec vault list, cnspec vault remove, and cnspec vault reset exit with an error that points to this page. To see, change, or remove a vault, edit the spec.vault block of your inventory file.

For the full encrypted-file options and how to reference the resulting secret from an asset, read Configure a vault from the CLI in the inventory file reference.

Last updated on

On this page