-
Notifications
You must be signed in to change notification settings - Fork 90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multi-line Environment Variables e.g: RSA Private Keys #17
Comments
Created a StackOverflow question: |
@nelsonic Try export the key
test.sh
Hope it works, if you are satisfied i will post on SO and gain some points 😉 |
Hi @cse-tushar, thank you so much for sharing your thoughts/solution! 🥇 That is a nicer solution than requiring a export PRIVATE_KEY=`cat ./gitbu.2018-03-23.private-key.pem` If you post it on StackOverflow I will up-vote. Feel free to include the following in your answer: If you want to save the key to an export HELLO_WORLD='-----BEGIN RSA PRIVATE KEY-----
MIIEpAIBAAKCAQEA04up8hoqzS1+APIB0RhjXyObwHQnOzhAk5Bd7mhkSbPkyhP1
...
iWlX9HNavcydATJc1f0DpzF0u4zY8PY24RVoW8vk+bJANPp1o2IAkeajCaF3w9nf
q/SyqAWVmvwYuIhDiHDaV2A==
-----END RSA PRIVATE KEY-----' So the following command will work:
Followed by: source .env Now the key will be in your Exclude below this point, it's only for "reference" ... I thought that the problem of including the private key string in the
https://stackoverflow.com/questions/38672680/replace-newlines-with-literal-n |
@nelsonic awesome bro :) awww |
I did not like the 1 |
There is a simple answer. Just surround the multi-line literal value with quotes:
|
I ended up replacing something like:
|
I'll add that a more elegant fool-proof way is to encode the env var as base64 and then decode it when you access it. const base64 = process.env.GITHUB_PRIVATE_KEY
const privateKey = Buffer.from(base64, 'base64') |
@LikeCarter this is the best answer i've seen so far. Seems to works perfectly. Thanks for mentioning it!... |
u can try this: makefile
|
One of our Apps
github-backup
requires the use of an RSA Private Key as an environment variable:e.g:
simply copy-pasting the key from the
.pem
into an.env
file or attempting to export it in the terminal e.g:Does not work ... because of the line breaks.
I did a bit of googling but did not find a workable solution ...
e.g: https://stackoverflow.com/questions/43082918/how-to-sett-multiline-rsa-private-key-environment-variable-for-aws-elastic-beans
Error:
followed the instructions in: http://blog.vawter.com/2016/02/10/Create-an-Environment-Variable-from-a-Private-Key
Created a file called
keytoenvar.sh
with the following lines:then ran the following command:
source keytoenvar.sh PRIVATE_KEY ./gitbu.2018-03-23.private-key.pem
That works but it seems like a "long-winded" approach ... 🤔
Does anyone know of a simpler way of doing this?
(I'm trying to make it as "beginner friendly" as possible...)
@SimonLab / @Cleop relates to GitBu environment variables specifically the GitHub App
PRIVATE_KEY
The text was updated successfully, but these errors were encountered: