Easy CA management
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
877 B

9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
  1. #!/usr/bin/env python3
  2. import argparse
  3. import json
  4. from os import path
  5. def main(args):
  6. result_dict = {}
  7. result_dict['keyType'] = 'ssh_user'
  8. result_dict['rootRequested'] = args.root_access
  9. result_dict['userName'] = args.user_name
  10. if path.exists(args.pub_key_path):
  11. with open(args.pub_key_path, 'r') as stream:
  12. key_data = stream.read().strip()
  13. else:
  14. key_data = args.pub_key_path
  15. result_dict['keyData'] = key_data
  16. request = { 'type': 'sign_request', 'request': result_dict }
  17. print(json.dumps(request))
  18. def get_parser():
  19. parser = argparse.ArgumentParser()
  20. parser.add_argument('pub_key_path')
  21. parser.add_argument('user_name')
  22. parser.add_argument('-r', '--root-access', action='store_true')
  23. return parser
  24. if __name__ == '__main__':
  25. parser = get_parser()
  26. main(parser.parse_args())