I have keys on path /v1/sys-kv2/data/secrets. The problem is that I can’t list via curl:
curl -k -v -H "X-Vault-Token: <>" -X GET https://localhost:8200/v1/sys-kv2/metadata/secrets | jq
I get:
< HTTP/2 404
{
"errors": []
}
Policy associated with token:
path "sys-kv2/*" {
capabilities = ["list","read"]
}
Give this one a try:
curl -k -v -H "X-Vault-Token: <>" -X GET https://localhost:8200/v1/sys-kv2/metadata/secrets?list=true | jq
I got the same answer:
< HTTP/2 404
{
"errors": []
}
Yes, exactly according to the instructions. Both versions v1 and v2 give the same answer as I mentioned above.
Does not seem you have key value in the metadata,
Do you have key value in metadata? then use this
curl -X 'GET' \
'https://localhost:8200/v1/sys-kv2/metadata/secrets' \
-H 'accept: application/json' \
-H 'X-Vault-Token: hvs.fgkg' | jq
If you dont use this
curl -X 'GET' \
'https://localhost:8200//v1/sys-kv2/data/secrets' \
-H 'accept: application/json' \
-H 'X-Vault-Token: hvs.fgkg' | jq
Yes, with the GET method, it returns a list of keys and values correctly. But I really want to use LIST to return a list without values.
tsiamer
8
To get only the keys without values, use this:
curl -X 'GET' \
'https://localhost:8200//v1/sys-kv2/data/secrets' \
-H 'accept: application/json' \
-H 'X-Vault-Token: hvs.fgkg' | jq -r '.data.data | keys[]'