12

So I'm setting up a really awesome hubot setup which will automatically deploy code from github to heroku, via a free heroku nodejs app. I'm having trouble checking out the repo properly on AWS. I created SSH keys on the remote box, had them working and verified it. Then, I added them as Heroku environment variables like this:

~$ heroku config:add PRIVATE_KEY="...
aoijsdfasoidjfasodijfasodifjaodsifjasdofija"

I then try to echo both the public and private keys back to their normal location in .ssh/id_rsa, but they ask me for a passphrase, which I didn't set, and always fail.

Any idea how to successfully write a key to an environment variable? I think it's something to do with the linebreaks not showing up correctly.

2 Answers 2

15

AH! Of course.

If you do echo "$VAR" it retains its formatting. Updating my scripts now.

(i had been working on this all day. Thank you rubber duck.)

4

If you would like to read from the key file, this works:

heroku config:set PRIVATE_KEY="$(cat id_rsa)"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.