Skip to content

Instantly share code, notes, and snippets.

@danielsamuels
Created November 15, 2017 17:22
Show Gist options
  • Save danielsamuels/1231c62b5e05a5f758fc06ce3c06b3ba to your computer and use it in GitHub Desktop.
Save danielsamuels/1231c62b5e05a5f758fc06ce3c06b3ba to your computer and use it in GitHub Desktop.
SSH authentication using a Github organisation as a source
#!/usr/bin/env python3
import json
from urllib.request import urlopen
def main():
with urlopen('https://api.github.com/orgs/onespacemedia/public_members') as f:
users = json.loads(f.read().decode('utf8'))
for user in users:
# Get the public keys for this user.
with urlopen('https://api.github.com/users/{}/keys'.format(user['login'])) as f:
keys = json.loads(f.read().decode('utf8'))
for key in keys:
print(key['key'])
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment