title: Setting up private Github access with AWS Elastic Beanstalk and Ruby container
body: <p>Going by a <a href="http://ruby.awsblog.com/post/Tx2AK2MFX0QHRIO/Deploying-Ruby-Applications-to-AWS-Elastic-Beanstalk-with-Git">recent tutorial</a> on setting up AWS Elastic Beanstalk for Ruby deployment using Git, I just set up a Elastic Beanstalk environment from my CI server. However, the application failed to start. I went through the logs to find that <code>bundle install</code> was failing with an error message.</p>
  
  <blockquote>
    <p>Fetching git@github.com:example/private-repository.git
    Host key verification failed.
    fatal: The remote end hung up unexpectedly
    [31mGit error: command <code>git clone 'git@github.com:example/private-repository.git' "/var/app/ondeck/vendor/cache/ruby/1.9.1/cache/bundler/git/private-repository-e4bbe6c2b13bb62664e39e345c1b01d80017934c" --bare --no-hardlinks</code> in directory /var/app/ondeck has failed.[0m</p>
  </blockquote>
  
  <p><code>Gemfile</code> of my Rails application contains references to gemified plugins hosted on a couple of my owned private repositories on Github. Something like</p>
  
  <blockquote>
    <p>gem 'somegemname', :git => 'git@github.com:example/private-repository.git'</p>
  </blockquote>
  
  <p>I had faced similar issues with Capistrano deployments which were resolved by setting up <code>ssh_options[:forward_agent] = true</code>. </p>
  
  <p>AWS Elastic Beanstalk Ruby container supports custom configuration through custom <code>.config</code> files placed under <code>.ebextensions</code>. Would setting up an SSH forward agent help in this case? Are there any other alternatives to reach a private Github repository while starting an Elastic Beanstalk environment?</p>
  
  <p>Update 1:
  I just checked for the user with which a <code>bundle install</code> is initiated. Found out that a script <code>/opt/elasticbeanstalk/hooks/appdeploy/pre/10_bundle_install.sh</code> starts <code>bundle install</code> as <code>root</code> user. I tried creating an SSH Key under <code>/root/.ssh</code> and added it's pub-key to Github Deploy keys for that repository. No luck so far. Will now try to add an SSH pub-key to my user account on Github so that it applies to all private repositories accessible through my Github account.</p>