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.
Tetiana Markova | September 13, 2016. Environment variables represent a kind of placeholders, where you can store the frequently used parameters' values or strings in order not to specify them manually in the code each time they are needed.
SSH keys are typically configured in an authorized_keys file in . ssh subdirectory in the user's home directory. Typically a system administrator would first create a key using ssh-keygen and then install it as an authorized key on a server using the ssh-copy-id tool.
You need to be able to transfer your public key to the remote system. Therefore, you must either be able to log into the remote system with an established account username and password/passphrase, or have an administrator on the remote system add the public key to the ~/. ssh/authorized_keys file in your account.
Open a terminal and use the ssh-keygen command with the -C flag to create a new SSH key pair. Replace the following: KEY_FILENAME : the name for your SSH key file. For example, a filename of my-ssh-key generates a private key file named my-ssh-key and a public key file named my-ssh-key.
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.)
If you would like to read from the key file, this works:
heroku config:set PRIVATE_KEY="$(cat id_rsa)"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With