vault commands

31 commands, each with a one-line explanation. Click a command to copy it, or its title for details.

Commands 31 shown

  • vault login <token>

    Authenticate to Vault using a token

  • vault write auth/approle/login role_id=<role> secret_id=<secret>

    Authenticate via AppRole auth method

  • vault kv get -mount=secret path/to/secret

    Read a KV v2 secret; add -format=json for scripting

    secrets

  • vault kv put -mount=secret path/to/secret key=value

    Write or update a KV v2 secret

    secrets

  • vault kv list -mount=secret path/to/

    List all keys under a KV path

    secrets

  • vault kv delete -mount=secret path/to/secret

    Soft-delete the latest version of a KV secret

    secrets

  • vault kv metadata get -mount=secret path/to/secret

    See all versions, creation dates, deletion status

    secrets

  • vault token create -policy=read-only -ttl=1h

    Issue a short-lived token limited to a specific policy

  • vault auth list

    Show all enabled auth backends in Vault

  • vault auth enable kubernetes && vault write auth/kubernetes/config kubernetes_host=https://$KUBERNETES_PORT_443_TCP_ADDR:443

    Enable and configure Kubernetes auth method

    config

  • vault write auth/kubernetes/role/my-role bound_service_account_names=<sa> bound_service_account_namespaces=<ns> policies=<policy> ttl=1h

    Bind a k8s ServiceAccount to a Vault policy

    config

  • vault policy write my-policy policy.hcl

    Upload an HCL policy file to Vault

    config

  • vault policy list

    List all policies in Vault

  • vault secrets enable -path=myapp kv-v2

    Mount a new secrets engine at a given path

    config

  • vault write transit/encrypt/my-key plaintext=$(echo -n 'secret' | base64)

    Encrypt data using Vault's transit encryption engine

    secrets

  • vault write transit/decrypt/my-key ciphertext=vault:v1:... | base64 -d

    Decrypt a ciphertext with transit engine

    secrets

  • vault token lookup

    Show TTL, policies, and capabilities of current token

  • vault token renew

    Extend the current token's TTL

  • vault status

    Show seal status, HA mode, cluster info

    debug

  • vault secrets enable -path=secret kv-v2

    Mount a KV version 2 secrets engine at 'secret/'

    security

  • vault kv put secret/myapp/config db_password=s3cr3t api_key=abc123

    Store multiple key-value pairs at a path

    security

  • vault kv get -format=json secret/myapp/config | jq '.data.data'

    Read a KV v2 secret and extract the data payload

    security

  • vault kv list secret/myapp/

    List all keys under a KV v2 prefix

    security

  • vault token create -policy=read-only -period=24h -display-name=ci-pipeline

    Issue a renewable token with a 24h TTL for CI

    security · ci

  • vault auth enable kubernetes && vault write auth/kubernetes/config kubernetes_host=https://kubernetes.default.svc

    Allow pods to authenticate with Vault via ServiceAccount JWT

    security · kubectl

  • vault read database/creds/readonly-role

    Obtain short-lived Postgres credentials from the database secrets engine

    security · postgres

  • vault operator seal vault operator unseal $UNSEAL_KEY

    Manually seal or unseal Vault with an unseal key shard

    security

  • vault kv patch -mount=secret app api_key=<id>

    Update one field without rewriting the whole secret; note: kv patch needs KV-v2

    secrets · troubleshooting

  • T=$(vault kv get -wrap-ttl=60s -field=wrapping_token -mount=secret app); vault unwrap $T

    Pass a secret as a single-use wrapping token; note: any reuse trips a security alarm

    secrets · security · troubleshooting

  • vault token capabilities database/creds/readonly

    Show effective ACL verbs the current token has on a path; fast policy debugging

    security · troubleshooting · observability

  • vault lease revoke -prefix database/creds/readonly

    Revoke all leases under a prefix to kill leaked dynamic DB creds instantly

    security · troubleshooting · secrets