Connect
export VAULT_ADDR=<url>
Set the server address
Default is https://127.0.0.1:8200
export VAULT_TOKEN=<token>
Authenticate via environment
Takes effect without a login; beats the cached token
vault status
Show seal and HA state
Exit code 0 unsealed, 2 sealed, 1 error
-format=json
Machine-readable output (also yaml)
Or set VAULT_FORMAT
-namespace=<ns>
Run inside a namespace (Enterprise)
Or set VAULT_NAMESPACE
-tls-skip-verify
Skip TLS verification (testing only)
-ca-cert=<file>
Trust a private CA
Or set VAULT_CACERT
Login and tokens
vault login
Log in with a token (prompts)
vault login -method=<type>
<key>=<value>
Log in with another auth method
For example -method=userpass username=alice
vault login -method=<type> -path=<path>
Auth method at a custom path
vault login -token-only -method=<type>
<key>=<value>
Print just the token
vault token lookup
Show the current token
vault token create -policy=<name>
Create a token with a policy
vault token create -ttl=<dur>
-use-limit=<n>
Short-lived, limited-use token
vault token create -period=<dur>
Periodic token for long-running services
Needs sudo capability
vault token renew
Extend the current token
vault token revoke <token>
Revoke a token and its children
vault token capabilities <path>
What can this token do here?
KV secrets
vault kv put -mount=secret <path>
<key>=<value>
Write a secret
On KV v2 this replaces all keys with a new version
vault kv get -mount=secret <path>
Read a secret
vault kv get -mount=secret -field=<key>
<path>
Print one field only
No trailing newline, good for $(...)
vault kv list -mount=secret
List paths under a mount
vault kv get -mount=secret -version=<n>
<path>
Read an older version
vault kv patch -mount=secret <path>
<key>=<value>
Change keys, keep the rest
vault kv put -mount=secret <path>
@<file>.json
Write from a JSON file
vault kv put -mount=secret <path> <key>=-
Read a value from stdin
Keeps it out of shell history
vault kv put -mount=secret -cas=<n> <path>
<key>=<value>
Write only if version matches
0 means only if it does not exist
vault kv delete -mount=secret <path>
Soft-delete the latest version
vault kv undelete -mount=secret -versions=<n>
<path>
Restore a deleted version
vault kv destroy -mount=secret -versions=<n>
<path>
Permanently remove versions
vault kv metadata get -mount=secret <path>
Show versions and settings
vault kv metadata delete -mount=secret <path>
Delete a secret and all history
vault kv rollback -mount=secret -version=<n>
<path>
Make an old version current
Engines and auth methods
vault secrets list
Show enabled secrets engines
vault secrets enable -path=<path> <type>
Enable an engine
For example kv-v2, transit, database
vault secrets disable <path>
Disable and wipe an engine
vault secrets tune -default-lease-ttl=<dur>
<path>
Change engine lease TTLs
vault auth list
Show enabled auth methods
vault auth enable <type>
Enable an auth method
For example userpass, approle, oidc
vault auth enable -path=<path> <type>
Enable at a custom path
vault auth disable <path>
Disable an auth method
vault write auth/userpass/users/<name>
password=<pw>
Add a userpass user
Add policies=<name> to grant access
Operate and seal
vault operator init
Initialize a new server
Prints unseal keys and root token once; store them safely
vault operator init -key-shares=<n>
-key-threshold=<n>
Choose key split
vault operator unseal
Enter one unseal key (prompts)
Repeat until the threshold is reached
vault operator seal
Seal the server
vault lease lookup <lease-id>
Inspect a lease
vault lease renew <lease-id>
Extend a lease
vault lease revoke <lease-id>
Revoke a lease now
vault audit enable file file_path=<file>
Log requests to a file
-wrap-ttl=<dur>
Wrap a response in a one-time token
vault unwrap <token>
Unwrap a wrapped response