1
votes

I am trying to deploy my first webapp to EC2 using capistrano and the repo is on github. But I am facing issues with "cap deploy:cold". The deploy.rb is pasted below. Following are the steps I followed.

1) Logged into ec2 instance using ssh from my local machine. Generated keys using ssh-keygen without any passphrase.

2) Took the contents of id_rsa.pub and copied to the github repo settings deploy keys.

3) Then from my local machine, ran "cap deploy:cold". I get the following error

user1@laptop:~/MyExample$ cap deploy:cold * 2013-03-01 19:08:06 executing deploy:cold'
* 2013-03-01 19:08:06 executing
deploy:update' ** transaction: start * 2013-03-01 19:08:06 executing `deploy:update_code' updating the cached checkout on all servers executing locally: "git ls-remote git@github.com:user1/MyExample.git HEAD" Permission denied (publickey). fatal: The remote end hung up unexpectedly * [deploy:update_code] rolling back * executing "rm -rf /var/www/MyExample.com/releases/20130301133835; true" servers: ["181.73.124.219"] [181.73.124.219] executing command command finished in 1186ms


set :application, "MyExample.com" set :scm, "git" set :repository, "git@github.com:thisuser/example.git"

default_run_options[:pty] = true

set :user, 'ubuntu' set :use_sudo, true set :deploy_to, "/var/www/#{application}" set :deploy_via, :remote_cache

role :web, "181.73.124.219" role :app, "181.73.124.219" role :db, "181.73.124.219", :primary => true

after "deploy", "deploy:bundle_gems" after "deploy:bundle_gems", "deploy:restart"

namespace :deploy do task :bundle_gems do run "cd #{deploy_to}/current && bundle install vandor/gems" end task :start do ; end task :stop do ; end task :restart, :roles => :app, :except => { :no_release => true } do run "#{try_sudo} touch #{File.join(current_path,'tmp','restart.txt')}" end end

What am I missing here? Also any pointers to a URL/blog that can provide detailed steps would help.

Thanks.

1
I believe this seems to be an issue with the keys, but not sure how to fix it. Any help appreciated.sthustfo
some more updates. I checked against help provided at help.github.com/articles/error-permission-denied-publickey. Everything is fine and even verified that the public key attached to github account is also same.sthustfo

1 Answers

0
votes

I managed to get it working. As seen in the log, executing locally: "git ls-remote git@github.com:user1/MyExample.git HEAD"

the capistrano is trying to run the above command local machine and not on the server. Running the above command on the terminal also returned the same error - Permission denied (Public Key).

So I had to copy the generated id_rsa and id_rsa.pub from the deploy server to the local machine. And after copying, add it to the ssk keys being used by running "ssh-add /path/to/keys".

After adding those keys, I was able to move ahead.