cluster-api-provider-hetzner icon indicating copy to clipboard operation
cluster-api-provider-hetzner copied to clipboard

Use `hcloud` cli in Makefile to upload ssh-keys

Open guettli opened this issue 1 year ago • 0 comments

/kind feature

Describe the solution you'd like

At the moment we use curl to upload ssh-keys.

At other places we already use the hcloud cli tool:

hcloud ssh-key create --name ${SSH_KEY_NAME} --public-key-from-file ${SSH_KEY_PATH}.pub

hcloud ssh-key create --name caph --public-key-from-file ~/.ssh/hetzner-cluster.pub

I think we should update this part in the Makefile, and use hcloud instead:

add-ssh-pub-key:
	./hack/ensure-env-variables.sh HCLOUD_TOKEN SSH_KEY SSH_KEY_NAME
	SSH_KEY_CONTENT=$$(cat $(SSH_KEY)) ; \
	curl -sS \
		-X POST \
		-H "Authorization: Bearer $${HCLOUD_TOKEN}" \
		-H "Content-Type: application/json" \
		-d '{"labels":{},"name":"${SSH_KEY_NAME}","public_key":"'"$${SSH_KEY_CONTENT}"'"}' \
		'https://api.hetzner.cloud/v1/ssh_keys'

guettli avatar Aug 15 '24 11:08 guettli