sks.py 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #!/usr/bin/python
  2. # -*- encoding:utf-8 -*-
  3. import json,pprint
  4. from prettyprinter import prettyPrinter
  5. from kscore.session import get_session
  6. if __name__ == "__main__":
  7. s = get_session()
  8. region='cn-beijing-6'
  9. # region='cn-shanghai-2'
  10. sksClient = s.create_client("sks", region, use_ssl=True)
  11. # 注:如果参数名中包含.请使用JSON格式数据,如参数名 KeyId.N 、 Filter.N.Name 、 Filter.N.Value.1
  12. # ------------------DescribeKeys(获取密钥列表信息)--------------------------
  13. param = {
  14. 'KeyId.1': '89e84941-41fb-43e3-8426-43676ac11b0b',
  15. 'MaxResults': 20,
  16. 'NextToken': 1
  17. }
  18. resp=sksClient.describe_keys(**param)
  19. print(resp)
  20. # ------------------CreateKey(创建密钥)--------------------------
  21. # param = {
  22. # 'KeyName': 'test'
  23. # }
  24. # resp = sksClient.create_key(**param)
  25. # print(resp)
  26. # ------------------ImportKey(导入密钥)--------------------------
  27. # param = {
  28. # 'KeyName': 'test-import',
  29. # "PublicKey": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQCcbmgQsS4zM43iFsCo31GtUfp1/cdTXhFha4MkvWnSQaz4Z7ehDHqx9nT2fadY1f0hBD4aNDO3bf+3zUSejOcJw15xlTtiNQ57ttH4LsG+6CP03h9WYYwcCtsnlaPfVr0LldSpLSiHa2UrhuAVItGe6v54+6e8ncueiA6fUW1jUw== root"
  30. # }
  31. # resp = sksClient.import_key(**param)
  32. # print(resp)
  33. # ------------------ModifyKey(修改密钥信息)--------------------------
  34. # param = {
  35. # 'KeyId': 'f3a5e823-2713-4ffc-920c-f0b57dffd8f8',
  36. # "KeyName": "test-update"
  37. # }
  38. # resp = sksClient.modify_key(**param)
  39. # print(resp)
  40. # ------------------DeleteKey(删除密钥)--------------------------
  41. # param = {
  42. # 'KeyId': 'f3a5e823-2713-4ffc-920c-f0b57dffd8f8'
  43. # }
  44. # resp = sksClient.delete_key(**param)
  45. # print(resp)