Going by a recent tutorial 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 bundle install
was failing with an error message.
Fetching [email protected]:example/private-repository.git Host key verification failed. fatal: The remote end hung up unexpectedly [31mGit error: command
git clone '[email protected]:example/private-repository.git' "/var/app/ondeck/vendor/cache/ruby/1.9.1/cache/bundler/git/private-repository-e4bbe6c2b13bb62664e39e345c1b01d80017934c" --bare --no-hardlinks
in directory /var/app/ondeck has failed.[0m
Gemfile
of my Rails application contains references to gemified plugins hosted on a couple of my owned private repositories on Github. Something like
gem 'somegemname', :git => '[email protected]:example/private-repository.git'
I had faced similar issues with Capistrano deployments which were resolved by setting up ssh_options[:forward_agent] = true
.
AWS Elastic Beanstalk Ruby container supports custom configuration through custom .config
files placed under .ebextensions
. 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?
Update 1:
I just checked for the user with which a bundle install
is initiated. Found out that a script /opt/elasticbeanstalk/hooks/appdeploy/pre/10_bundle_install.sh
starts bundle install
as root
user. I tried creating an SSH Key under /root/.ssh
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.
ssh -v github.com
: debug1: Trying private key: /root/.ssh/github debug1: key_parse_private2: missing begin marker debug1: key_parse_private_pem: PEM_read_PrivateKey failed debug1: read PEM private key done: type <unknown> Enter passphrase for key '/root/.ssh/github': – Hass