secret correct

This commit is contained in:
Mateusz 2023-01-22 19:01:16 +01:00
parent d39ee251a5
commit 8ff2d32e51

View File

@ -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")