Skip to content

Instantly share code, notes, and snippets.

@WanLinLin
Created August 2, 2022 09:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save WanLinLin/fb529bd63ccad6363a4c8bd4cf0bee82 to your computer and use it in GitHub Desktop.
Save WanLinLin/fb529bd63ccad6363a4c8bd4cf0bee82 to your computer and use it in GitHub Desktop.
get keys in CI
### in local ###
# gen private key
openssl genrsa -aes128 -out private.pem 4096
# gen public key from private key
openssl rsa -in private.pem -pubout > public.pem
### in CI ###
# setup the $PUB secret in the CI platform settings, create public key in CI steps
echo "$PUB" > public.pem
touch msg
printenv KEY_YOU_WANT_1 >> msg
printenv KEY_YOU_WANT_2 >> msg
# copy the output in the CI console
openssl rsautl -encrypt -inkey public.pem -pubin -in msg | base64
### in local ###
# paste the clipboard to "in" file, decrypt it to "out" file
cat in | base64 -d | openssl rsautl -decrypt -inkey private.pem > out
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment