title: How to set multiline RSA private key environment variable for AWS Elastic Beans
body: <p>I am deploying a Ruby on Rails application to AWS using Elastic Beanstalk and have to set a private key as an environment variable</p>
  
  <p>E.g  </p>
  
  <p><code>-----BEGIN RSA PRIVATE KEY-----
  SpvpksXQIBA65ICOgQxV2TvMIICAiMeV9prhdJSKjjsk2
  tYdz8lhn/ibROQW71utuHLAyHGMBxz3kIaaIq1kjdkkk
  tYdz8lhn/ibROQW71utuHLAyHGMBxz3kIaaIq1kjdkkk
  tYdz8lhn/ibROQW71utuHLAyHGMBxz3kIaaIq1kjdkkk
  tYdz8lhn/ibROQW71utuHLAyHGMBxz3kIaaIq1kjdkkk
  -----END RSA PRIVATE KEY-----
  </code></p>
  
  <p>However this doesn't seem to work when deploying the app as it always fails with a</p>
  
  <blockquote>
    <p>OpenSSL::PKey::RSAError: Neither PUB key nor PRIV key: nested asn1
    error</p>
  </blockquote>
  
  <p>I think it's because the RSA Key is malformed. </p>
  
  <p>However unlike in Heroku, AWS EB does not accept multiline input (see below) so I have to use <code>\n</code> to create new lines. </p>
  
  <p><a href="https://i.stack.imgur.com/xb4wi.png" rel="noreferrer"><img src="https://i.stack.imgur.com/xb4wi.png" alt="enter image description here"></a></p>
  
  <p>I tried with few different styles but none of them seem to interpolate the <code>\n</code> properly and I always keep getting the same error.</p>
  
  <p>I've tried with <code>\n</code> and the end of each line, then <code>\\n</code> and also tried tried double quotes <code>\"</code> to wrap the key but I still keep getting the same error.</p>
  
  <p>How do I properly set a multiline environment variable in AWS Elastic Beanstalk ?</p>