From 1e51967f957a989c70591e73516a05aaec02a8b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20Kl=C3=BCter?= Date: Fri, 22 May 2020 17:04:25 +0200 Subject: [PATCH] Added script to list sshkeys --- sshkeys.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100755 sshkeys.py diff --git a/sshkeys.py b/sshkeys.py new file mode 100755 index 0000000..cc2374b --- /dev/null +++ b/sshkeys.py @@ -0,0 +1,21 @@ +#!/usr/bin/env python3 +from hcloud import Client, APIException +import argparse + +# Get Servername +parser = argparse.ArgumentParser() +parser.add_argument("apiKey") + +args = parser.parse_args() + +apiKey = args.apiKey + +try: + client = Client(token=apiKey) + ssh_keys = client.ssh_keys.get_all() + + for ssh_key in ssh_keys: + print("Key Name:", ssh_key.name) + +except APIException as e: + print("API Error ", e)