Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vault: Get key value secrets

I've created this secret backend:

$ vault secrets enable -path=openshift kv
$ vault write openshift/postgresql username=tdevhub
$ vault write openshift/postgresql password=password

I don't quite figure out how to read username and password values.

I've tried with:

$ vault read openshift/postgresql/password

or

$ vault kv get openshift/post...

By other hand, when I perform this command line:

$ vault kv get openshift/postgresql                   
====== Data ======
Key         Value
---         -----
username    tdevhub

I'd like to store username and password into a secret backend. I've realized that a kv secret backend only is able to store one key... is it right?

How could I get my goal?

like image 369
Jordi Avatar asked Aug 31 '26 00:08

Jordi


2 Answers

you can read secrets using

vault kv get -field=password openshift/postgresql

or

vault kv get -field=username openshift/postgresql
like image 163
hkhelil Avatar answered Sep 01 '26 12:09

hkhelil


You can use the flags -format json and -field=data to get all the data under a given key properly formatted in JSON. This also filters out the extra details.

vault kv get -format json -field=data openshift/postgresql

The output you would get is -

{
  "username": "tdevhub",
  "password": "password"
}
like image 21
Lakhan Saiteja Avatar answered Sep 01 '26 13:09

Lakhan Saiteja



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!