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.

RandallB
  • 5,415
  • 6
  • 34
  • 47

2 Answers2

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.)

RandallB
  • 5,415
  • 6
  • 34
  • 47
4

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

heroku config:set PRIVATE_KEY="$(cat id_rsa)"
Harrison Powers
  • 359
  • 1
  • 7
  • 16