views:

833

answers:

3
+1  Q: 

capistrano problem

Hi all

I am having a problem with deploying my application to my server.

I have msysgit, github and capistrano installed and working.

I have successfully pushed my app to github and can successfully run cap deploy:setup to setup on my server from my local machine.

BUT..

When I run cap deploy:cold it asks me for my passphrase to connect to github repo then it asks it again to connect to my server but then it gives me an error permission denied (public key) and rools back.

It seems like this is an error with my keys but how can it then connect to my server to do the cap deplo:setup ?

My public keys are the same in both github and my server is this correct ?

Also when running cap deploy:setup it asks me for my user server password is this correct ?

Please help as this has delayed me for days already

This is the error:

$ cap deploy * executing deploy' * executing deploy:update' ** 
transaction: start * executing `deploy:update_code' executing locally: 
"git ls-remote [email protected]:rmossuk/Macrotec.git master " 
Enter passphrase for key '/c/Users/Rick/.ssh/id_rsa': * 
executing "git clone -q [email protected]:rmossuk/Macrotec.git /usr/local/lib/r uby/gems/1.9.1/gems/passenger-2.2.4/test/stub/rails_apps/Macrotec/releases/20090723213346 && cd /usr/local/lib/ruby/gems/1.9.1/gems/passenger-2.2.4/test/stub/ra ils_apps/Macrotec/releases/20090723213346 && git checkout -q -b deploy a28798bc0 d3b5688453a58bf4917d6c931187a7a && (echo a28798bc0d3b5688453a58bf4917d6c931187a7 a > /usr/local/lib/ruby/gems/1.9.1/gems/passenger-2.2.4/test/stub/rails_apps/Mac rotec/releases/20090723213346/REVISION)" servers: ["macclesfieldnutrition.co.uk"] 
Enter passphrase for c:/Users/Rick/.ssh/id_rsa: 
[macclesfieldnutrition.co.uk] executing command ** 
[macclesfieldnutrition.co.uk :: out] Permission denied (publickey). ** 
[macclesfieldnutrition.co.uk :: out] fatal: The remote end hung up 
unexpecte dly command finished *** [deploy:update_code] rolling back * 
executing "rm -rf /usr/local/lib/ruby/gems/1.9.1/gems/passenger-2.2.4/test/s tub/rails_apps/Macrotec/releases/20090723213346; true" 
servers: 
["macclesfieldnutrition.co.uk"] [macclesfieldnutrition.co.uk] 
executing command command finished failed: "sh -c 'git clone -q [email protected]:rmossuk/Macrotec.git /usr/local/lib/ ruby/gems/1.9.1/gems/passenger-2.2.4/test/stub/rails_apps/Macrotec/releases/20090723213346 && cd /usr/local/lib/ruby/gems/1.9.1/gems/passenger-2.2.4/test/stub/r ails_apps/Macrotec/releases/20090723213346 && git checkout -q -b deploy a28798bc 0d3b5688453a58bf4917d6c931187a7a && (echo a28798bc0d3b5688453a58bf4917d6c931187a 7a > /usr/local/lib/ruby/gems/1.9.1/gems/passenger-2.2.4/test/stub/rails_apps/Ma crotec/releases/20090723213346/REVISION)'" on macclesfieldnutrition.co.uk

Thanks alot rick

A: 

What are the permissions set at for your keys? They should be chmod'd to 0600.

Can you ssh into your server without entering a password? When you generated your keys, did you enter a passphrase? If you did, you might find it easier to regenerate them without the passphrase.

Mr. Matt
i can ssh into my server with just a passphrase, does this mean permissions for my keys are setup correctly ?
+1  A: 

You should have on your server (where you want deploy) installed yours access keys for git server.

You should have yours key files (with chmod 600):

id_rsa

id_rsa.pub

in ~/.ssh directory (with chmod 700) on server in deploy user home

you probably have that keys only on your local development computer.

You can add for your deploy file hook for 'setup:cold' where will be automated upload of your local keys files.

Andrzej Śliwa
what so you have a public and private key on both my local machine and my server ? should these be exactly the same ?i thought you just have public private on local machine and then copy the pulic to server ?the thing is aswll is that i can ssh user@server and enter my pass phrase and it will conect to the server this way. ???
you want deploy using git, and capistrano want pull code from server side, not from your computer and that is reason why you should have git access keys on server account. You must divide ssh access to server from your computer and access to git server from server (to get last sources). You dont uploading sources from local computer, you requesting deployment via git on server side.
Andrzej Śliwa
+1  A: 

If I add this to my deploy.rb file

set :ssh_options, {:forward_agent => true}
on :start do    
  `ssh-add`
end

I get this different error

$ cap deploy
    triggering start callbacks for `deploy'
Could not open a connection to your authentication agent.
  * executing `deploy'
  * executing `deploy:update'
 ** transaction: start
  * executing `deploy:update_code'
    executing locally: "git ls-remote [email protected]:rmossuk/Macrotec.git master
"
Enter passphrase for key '/c/Users/Rick/.ssh/id_rsa':
  * executing "git clone -q [email protected]:rmossuk/Macrotec.git /usr/local/lib/ruby/gems/1.9.1/gems/passenger-2.2.4/test/stub/rails_apps/Macrotec/releases/20090724112629 && cd /usr/local/lib/ruby/gems/1.9.1/gems/passenger-2.2.4/test/stub/rails_apps/Macrotec/releases/20090724112629 && git checkout -q -b deploy a28798bc0d3b5688453a58bf4917d6c931187a7a && (echo a28798bc0d3b5688453a58bf4917d6c931187a7a > /usr/local/lib/ruby/gems/1.9.1/gems/passenger-2.2.4/test/stub/rails_apps/Macrotec/releases/20090724112629/REVISION)"
    servers: ["macclesfieldnutrition.co.uk"]
Enter passphrase for c:/Users/Rick/.ssh/id_rsa:
    [macclesfieldnutrition.co.uk] executing command
*** [deploy:update_code] rolling back
  * executing "rm -rf /usr/local/lib/ruby/gems/1.9.1/gems/passenger-2.2.4/test/stub/rails_apps/Macrotec/releases/20090724112629; true"
    servers: ["macclesfieldnutrition.co.uk"]
 ** [deploy:update_code] exception while rolling back: TypeError, can't convert
Net::SSH::Authentication::Pageant::Socket into IO
c:/InstantRails/ruby/lib/ruby/gems/1.8/gems/capistrano-2.5.8/lib/capistrano/processable.rb:25:in `select': can't convert Net::SSH::Authentication::Pageant::Socket into IO (TypeError)
        from c:/InstantRails/ruby/lib/ruby/gems/1.8/gems/capistrano-2.5.8/lib/capistrano/processable.rb:25:in `process_iteration'
        from c:/InstantRails/ruby/lib/ruby/gems/1.8/gems/capistrano-2.5.8/lib/capistrano/command.rb:163:in `process!'
        from c:/InstantRails/ruby/lib/ruby/gems/1.8/gems/capistrano-2.5.8/lib/capistrano/command.rb:162:in `loop'
        from c:/InstantRails/ruby/lib/ruby/gems/1.8/gems/capistrano-2.5.8/lib/capistrano/command.rb:162:in `process!'
        from c:/InstantRails/ruby/lib/ruby/gems/1.8/gems/capistrano-2.5.8/lib/capistrano/command.rb:133:in `process'
        from c:/InstantRails/ruby/lib/ruby/gems/1.8/gems/capistrano-2.5.8/lib/capistrano/configuration/actions/invocation.rb:173:in `run_tree'
        from c:/InstantRails/ruby/lib/ruby/gems/1.8/gems/capistrano-2.5.8/lib/capistrano/configuration/connections.rb:172:in `execute_on_servers'
        from c:/InstantRails/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `each_slice'
         ... 40 levels...
        from c:/InstantRails/ruby/lib/ruby/gems/1.8/gems/capistrano-2.5.8/lib/capistrano/cli/execute.rb:14:in `execute'
        from c:/InstantRails/ruby/lib/ruby/gems/1.8/gems/capistrano-2.5.8/bin/cap:4
        from c:/InstantRails/ruby/bin/cap:19:in `load'
        from c:/InstantRails/ruby/bin/cap:19