- Create a directory using
mkdir -p vault/data
The vault config is stored here - create vault-config.hcl file and set its properties
ui = true disable_mlock = true #prevent memory from being swapped to disk storage "raft" { path = "./vault/data" node_id = "node1" } listener "tcp" { address = "0.0.0.0:8200" tls_disable = "true" } api_addr = "http://127.0.0.1:8200" cluster_addr = "https://127.0.0.1:8201"
- run
vault server -config=./vault-config.hcl
- run the cmd
$ export VAULT_ADDR=http://localhost:8200
this is what vault is listening on - check you're able to connect to the vault server using
vault status
- you might see Initialized value as False, this means vault server is running but hasn't been initialized
- To initialize vault run cmd
vault operator init -key-shares=1 -key-threshold=1
- store vault token and unseal key
- run the cmd
export VAULT_TOKEN=token
to communicate with vault - unseal vault
vault operator unseal
- create logs directory
- set log file dir
vault audit enable file file_path=./logs/audit.log
- you can use jq to parse json in terminal and see logs as json in terminal
tail -f ./logs/audit.log | jq
- if you dont have jq install it using brew on mac, and for other OS use your package manager
- go to http://localhost:8200
- authenticate using your root token
- To store K,V secrets in vault enable the kv engine using
vault secrets enable -path="kv-v1" -description="K/V v1" kv
- Check the secrets engines enabled using
vault secrets list
you should now see it under the list of enabled engines
Path | Type | Accessor | Description |
---|---|---|---|
cubbyhole/ | cubbyhole | cubbyhole_167e309c | per-token private secret storage |
identity/ | identity | identity_8e1a9832 | identity store |
kv-v1/ | kv | kv_dc8d4e16 | Test K/V v1 |
sys/ | system | system_5b73c140 | system endpoints used for control, policy and debugging |
- Now to store a key-valur pair use cmd
vault kv put kv-v1/<DEFINE PATH> <KEY>=VALUE>
e.gvault kv put kv-v1/aws-apiKey awsApiKey=AAaaBBccDDeeOTXzSMT1234BB_Z8JzG7JkSVxI
4.Check your UI