Helm (go template) to generate an ssh key and display the public part

Viewed 887

I can generate an ssh key with Sprig quite easily. But ideally I just need to put it in k8s secrets and display the public part to the user to import on the remote end.

https://play.golang.org/p/9oFBr9LD190 (for a full go example, but I don't get Go, just sprig in Helm.)

The Helm template alone just needs the template bit : {{ genPrivateKey "rsa" }} to show the text of a key to go into secrets. But other than giving the user the command to query the key from the secret and run it through ssh-keygen :

kubectl get secret ... -o jsonpath=".data.ssh-key" | base64 -d | ssh-keygen -y -f/dev/stdin

is there a way to persuade Sprig to get the public part of the key? (Commands unchecked, but you get the idea.)

0 Answers
Related