Skip to content

Commit 73bd456

Browse files
committed
docs: add secure example for getting secret values
The current example showing how to decode a secret does it in several steps which is fine but if some level of security is required will leak the encoded secret value in the shell history thus making it retrievable. This patch adds an example on how to retrieve that value without exposing it.
1 parent e60da5b commit 73bd456

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

content/en/docs/tasks/configmap-secret/managing-secret-using-kubectl.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,12 @@ The output is similar to:
130130
Now you can decode the `password` data:
131131

132132
```shell
133+
# This is an example for documentation purposes.
134+
# If you did things this way, the data 'MWYyZDFlMmU2N2Rm' could be stored in
135+
# your shell history.
136+
# Someone with access to you computer could find that remembered command
137+
# and base-64 decode the secret, perhaps without your knowledge.
138+
# It's usually better to combine the steps, as shown later in the page.
133139
echo 'MWYyZDFlMmU2N2Rm' | base64 --decode
134140
```
135141

@@ -139,6 +145,15 @@ The output is similar to:
139145
1f2d1e2e67df
140146
```
141147

148+
In order to avoid storing a secret encoded value in your shell history, you can
149+
run the following command:
150+
151+
```shell
152+
kubectl get secret db-user-pass -o jsonpath='{.data.password}' | base64 --decode
153+
```
154+
155+
The output shall be similar as above.
156+
142157
## Clean Up
143158

144159
Delete the Secret you created:

0 commit comments

Comments
 (0)