Skip to content

Instantly share code, notes, and snippets.

@gaieges
Last active November 2, 2020 18:18
Show Gist options
  • Save gaieges/fbb51fed9a2da6a593cb83c20bd39de5 to your computer and use it in GitHub Desktop.
Save gaieges/fbb51fed9a2da6a593cb83c20bd39de5 to your computer and use it in GitHub Desktop.
Getting all k8s secrets in plaintext

Couldn't find any tools out there aside from ksd which is great in a case where you need to look at individual secrets, but doesn't work if you are looking through many secrets.

How

Instead, I managed to find a way to do this in a bash shell instead:

# get all secrets
kubectl get secrets -o json --all-namespaces > /tmp/all.json

# use jq to look through and dump all the cleartext secret values:
for f in $(jq '.items[].data | select(. != null) | to_entries | .[].value' /tmp/all.json  -r ); do echo -n "$f" | base64 -D >> /tmp/plaintext.txt; done;

Improvements

  • Print the key & namespace out as well, on a previous line
  • Probably a better way to do the jq command
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment