Bootstrap FreeKB - Hashicorp Vault - Create a secret using the vault kv command
Hashicorp Vault - Create a secret using the vault kv command

Updated:   |  Hashicorp Vault articles

This assumes the following has already been done.

Let's say the secrets engine has been enabled with -path=secret/

~]# vault secrets enable -path=secret/ kv
Success! Enabled the kv secrets engine at: secret/

 

And let's say approle has been enabled and there is a role named "my-role" and contains a policy named "my-policy".

~]$ vault read auth/approle/role/my-role
Key                        Value
---                        -----
policies                   [my-policy]

 

In this example, since the secrets engine has been enabled with -path=secret/ the policy path will need to begin with secret/

Let's say "my-policy" permits the following capabilities to "secret/my_path/*".

~]$ vault policy read my-policy
path "secret/my_path/*" {
  capabilities = ["create", "delete", "list", "patch", "read", "update"]
}

The vault kv put command can be used to create a secret. In this example, a secret named "demo" that contains a key of "foo" and a value of "bar" will be created at secret/my_path/demo.

~]# vault kv put secret/my_path/demo foo=bar
Key              Value
---              -----
created_time     2021-08-20T06:23:36.4062144572
deletion_time    n/a
destroyed        false
version          1

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter b31fa7 in the box below so that we can be sure you are a human.