Masterminds / sprig

Useful template functions for Go templates.
http://masterminds.github.io/sprig/
MIT License
4.28k stars 442 forks source link

public/private ssh rsa keys #208

Open louiseohalloran opened 5 years ago

louiseohalloran commented 5 years ago

Hi Can you tell me if there is any way to generate public and private ssh rsa keys using sprig

I mean the equivalent to running ssh-keygen ?

Thanks

mattfarina commented 5 years ago

There are functions documented at https://masterminds.github.io/sprig/crypto.html that might help. These include examples.

louiseohalloran commented 5 years ago

Thanks @mattfarina, I did have a look there but I think there is no function to create the public and private key pair generated when you run ssh-keygen ( id_rsa, id_rsa.pub )

louiseohalloran commented 5 years ago

I think something like https://gist.github.com/devinodaniel/8f9b8a4f31573f428f29ec0e884e6673#file-gistfile1-txt-L81 would be needed

rally25rs commented 4 years ago

Anyone have a solution for this? I need to mount a public key file to a Kubernetes pod without mounting the private key portion.

max-allan commented 3 years ago

You can generate a private key (which includes the public key) like this : https://play.golang.org/p/I4NIZ-xY1w0

However, the function to get the public key (getPublicKey) seems not to be exposed. https://github.com/Masterminds/sprig/blob/master/crypto.go#L258 It also maybe wants a "PrivateKey" type object not the string that the private key returns.

thomas10-10 commented 7 months ago

that could be awesome to create ssh keyPair !!