A simple and safe way to share secrets

“What was that? We need to set up the secrets in our new repository, so our CI can run? No problem, I can do it; just copy-paste the secrets in our private chat!:x:

I was going through this exact situation, when @0x12b showed me a cool way to share the secret – so cool, in fact, that I’m writing this short post about it :upside_down_face:

You can (and should) encrypt the secret, but it’s tedious, because you have to:

  • find the public key of the person you want to share it with;
  • remember how to encrypt something.

There’s a solution to both problems:

  • curl https://github.com/<username>.keys, to get someone’s GitHub public key from their username;
  • age, to encrypt/decrypt the secret.

All you have to do is encrypt the file:

curl https://github.com/lucabello.keys | age -R - <secret-file> > secret-file.age

You can also encrypt the file for more recipients at the same time:

gh_keys=$(for gh_user in lucabello <someone-else>; do curl https://github.com/$gh_user.keys; done); echo $gh_keys | age -R - <secret-file> > secret-file.age

Now you can send secret-file.age via Matrix to your colleagues; they can decrypt it by passing their private key to age:

age --decrypt -i <private-key> secret-file.age

Hope this helps! :sparkles:

6 Likes

Neat stuff!

2 Likes