From 8ff2d32e5143d54da6ababe62db6264dfc58f1a7 Mon Sep 17 00:00:00 2001 From: Mateusz Date: Sun, 22 Jan 2023 19:01:16 +0100 Subject: [PATCH] secret correct --- IasS/ex1-2/hetzner-gitea-init.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/IasS/ex1-2/hetzner-gitea-init.py b/IasS/ex1-2/hetzner-gitea-init.py index 3609ba2..d36c28f 100644 --- a/IasS/ex1-2/hetzner-gitea-init.py +++ b/IasS/ex1-2/hetzner-gitea-init.py @@ -4,14 +4,21 @@ from hcloud.locations.domain import Location from hcloud.images.domain import Image from hcloud.server_types.domain import ServerType import time +from pathlib import Path + +with open("../token.txt", "r") as file: + api_token = file.read().strip() + +with open(f'{str(Path.home())}/.ssh/id_ed25519.pub', 'r') as file: + ssh_key = file.readline() client = Client( - token="KccUEiddxtzGoLWSNC3V8tylq7MYHCjdnShtgasQ8jSbHqCjGoaa6Rq7yoz4uS23" + token=api_token ) PREFIX = "s444498" -YOUR_LOCAL_SSH_PUBKEY = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIAj15oTbXA0KGBw5V/76KXDgJZpLNrxUO/rTA0u0eRl1 wirus@wirusowylapek" + try: - ssh_key = client.ssh_keys.create(name=f"{PREFIX}-pzc-ssh-key-2", public_key=YOUR_LOCAL_SSH_PUBKEY) + ssh_key = client.ssh_keys.create(name=f"{PREFIX}-pzc-ssh-key-2", public_key=ssh_key) print(f"Key {ssh_key.data_model.name} created: {ssh_key.data_model.public_key}") except: ssh_key = client.ssh_keys.get_by_name(f"{PREFIX}-pzc-ssh-key-2")