2019-06-10 17:41:55 +00:00
|
|
|
---
|
2020-01-18 00:18:09 +00:00
|
|
|
layout: docs
|
|
|
|
page_title: kv get - Command
|
2019-06-10 17:41:55 +00:00
|
|
|
description: |-
|
|
|
|
The "kv get" command retrieves the value from Vault's key-value store at the
|
|
|
|
given key name. If no key exists with that name, an error is returned. If a
|
|
|
|
key exists with that name but has no data, nothing is returned.
|
|
|
|
---
|
|
|
|
|
|
|
|
# kv get
|
|
|
|
|
|
|
|
The `kv get` command retrieves the value from K/V secrets engine at the given
|
|
|
|
key name. If no key exists with that name, an error is returned. If a key exists
|
|
|
|
with the name but has no data, nothing is returned.
|
|
|
|
|
|
|
|
## Examples
|
|
|
|
|
|
|
|
Retrieve the data of the key "creds":
|
|
|
|
|
2020-05-21 17:18:17 +00:00
|
|
|
```shell-session
|
2022-06-15 23:07:50 +00:00
|
|
|
$ vault kv get -mount=secret creds
|
|
|
|
== Secret Path ==
|
|
|
|
secret/data/creds
|
|
|
|
|
|
|
|
======= Metadata =======
|
|
|
|
Key Value
|
|
|
|
--- -----
|
|
|
|
created_time 2022-06-15T20:23:40.067093Z
|
|
|
|
custom_metadata <nil>
|
|
|
|
deletion_time n/a
|
|
|
|
destroyed false
|
|
|
|
version 1
|
2019-06-10 17:41:55 +00:00
|
|
|
|
|
|
|
====== Data ======
|
|
|
|
Key Value
|
|
|
|
--- -----
|
|
|
|
passcode my-long-passcode
|
|
|
|
```
|
|
|
|
|
|
|
|
If K/V Version 1 secrets engine is enabled at "secret", the output has no
|
|
|
|
metadata since there is no versioning information associated with the data:
|
|
|
|
|
2020-05-21 17:18:17 +00:00
|
|
|
```shell-session
|
2022-06-15 23:07:50 +00:00
|
|
|
$ vault kv get -mount=secret creds
|
2019-06-10 17:41:55 +00:00
|
|
|
====== Data ======
|
|
|
|
Key Value
|
|
|
|
--- -----
|
|
|
|
passcode my-long-passcode
|
|
|
|
```
|
|
|
|
|
2020-01-08 23:58:10 +00:00
|
|
|
Return only the "creds" "passcode" key:
|
|
|
|
|
2020-05-21 17:18:17 +00:00
|
|
|
```shell-session
|
2022-06-15 23:07:50 +00:00
|
|
|
$ vault kv get -mount=secret -field=passcode creds
|
2020-01-08 23:58:10 +00:00
|
|
|
my-long-passcode
|
|
|
|
```
|
|
|
|
|
2019-06-10 17:41:55 +00:00
|
|
|
## Usage
|
|
|
|
|
2023-07-18 21:07:55 +00:00
|
|
|
### Output options
|
2019-06-10 17:41:55 +00:00
|
|
|
|
|
|
|
- `-field` `(string: "")` - Print only the field with the given name. Specifying
|
|
|
|
this option will take precedence over other formatting directives. The result
|
|
|
|
will not have a trailing newline making it ideal for piping to other
|
2020-01-18 00:18:09 +00:00
|
|
|
processes.
|
2019-06-10 17:41:55 +00:00
|
|
|
|
|
|
|
- `-format` `(string: "table")` - Print the output in the given format. Valid
|
|
|
|
formats are "table", "json", or "yaml". This can also be specified via the
|
|
|
|
`VAULT_FORMAT` environment variable.
|
|
|
|
|
2023-07-18 21:07:55 +00:00
|
|
|
### Command options
|
2019-06-10 17:41:55 +00:00
|
|
|
|
2022-06-15 23:07:50 +00:00
|
|
|
- `-mount` `(string: "")` - Specifies the path where the KV backend is mounted.
|
|
|
|
If specified, the next argument will be interpreted as the secret path. If
|
|
|
|
this flag is not specified, the next argument will be interpreted as the
|
|
|
|
combined mount path and secret path, with /data/ automatically inserted for
|
|
|
|
KV v2 secrets.
|
|
|
|
|
2019-06-10 17:41:55 +00:00
|
|
|
- `-version` `(int: 0)` - Specifies the version to return. If not set the
|
2020-01-18 00:18:09 +00:00
|
|
|
latest version is returned.
|