Created
November 5, 2015 14:54
-
-
Save michaelkrieg/1b68e7d0c2ae971c1754 to your computer and use it in GitHub Desktop.
Unseal Vault Secret Storage
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import re | |
import random | |
import subprocess | |
initfile = "/usr/local/etc/vault/.init" | |
data = "" | |
with open(initfile, "r") as ifile: | |
data = ifile.read() | |
findkeys = re.compile(r'(?:Key\s\d+:\s)(.+)') | |
allkeys = findkeys.findall(data) | |
for x in range(0, 3): | |
randomkey = random.choice(allkeys) | |
allkeys.remove(randomkey) | |
print("vault unseal %s" % randomkey) | |
try: | |
out = subprocess.check_output(['vault', 'unseal', randomkey], stderr=subprocess.STDOUT) | |
except subprocess.CalledProcessError as e: | |
emsg = e.output | |
ecode = e.returncode | |
print("exited with code %s and message: %s." % (emsg, ecode)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
and yes, of course, the above is no production Vault!