Last active
August 29, 2015 14:21
-
-
Save tyrelsouza/12516139976bceb4a6b0 to your computer and use it in GitHub Desktop.
Import Keybase Keys you are Tracking into GnuPG
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
import gnupg | |
import urllib | |
from subprocess import Popen, PIPE | |
import os | |
from pprint import pprint | |
def get_names(): | |
p = Popen(['keybase', 'list-tracking'], stdin=PIPE, stdout=PIPE, stderr=PIPE) | |
output, err = p.communicate() | |
rc = p.returncode | |
if rc == 0: | |
return output.split() | |
return [] | |
def get_keyfile(username): | |
URL = "https://keybase.io/{username}/key.asc".format(username=username) | |
asc = urllib.urlopen(URL).read() | |
return asc | |
def import_keyfiles(keyfile): | |
gpg = gnupg.GPG(gnupghome=os.path.join(os.path.expanduser('~'),".gnupg")) | |
import_result = gpg.import_keys(keyfile) | |
return import_result.results | |
def main(): | |
results = [] | |
names = get_names() # Assuming you're tracking at least one person. Otherwise why would you run this? | |
keyfiles = [get_keyfile(name) for name in names] | |
for result in keyfiles: | |
results.extend(import_keyfiles(result)) | |
pprint(results) | |
if __name__ == "__main__": | |
main() |
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
python-gnupg |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment