HashiCorp Vault
Logging in, reading and writing KV secrets, policies, tokens, and server status and unseal.
Connecting
Point the CLI at a server
export VAULT_ADDR=https://<vault_host>:8200
Log in with OIDC (SSO)
vault login -method=oidcWho am I (current token)
vault token lookupServer status (sealed? HA mode?)
vault statusKV secrets
Read a secret
vault kv get secret/<vault_path>
Read one field only
vault kv get -field=password secret/<vault_path>
Write a secret
vault kv put secret/<vault_path> username=app password=secret
Values typed on the command line end up in shell history — prefer password=@file or -.
Update one field, keep the others
vault kv patch secret/<vault_path> password=new-secret
List secrets under a path
vault kv list secret/<vault_path>
Version history and rollbackadvanced
vault kv metadata get secret/<vault_path> && vault kv rollback -version=2 secret/<vault_path>
Policies and tokens
List policies
vault policy listShow a policy
vault policy read <vault_policy>
Create a policy from a fileadvanced
vault policy write <vault_policy> policy.hcl
Create a short-lived token with a policyadvanced
vault token create -policy=<vault_policy> -ttl=1h
What can this token do on a pathadvanced
vault token capabilities secret/data/<vault_path>
Operations
Unseal (repeat with different key shares)advanced
vault operator unsealEnabled secret engines and auth methods
vault secrets list && vault auth listRaft cluster peersadvanced
vault operator raft list-peers