capistrano问题

我在将应用程序部署到服务器时遇到问题。

我有msysgit,github和capistrano安装和工作。

我已经成功地将我的应用程序推送到github,并可以成功运行cap deploy:setup从我的本地机器安装到我的服务器上。

但..

当我运行cap deploy:cold它要求我的密码连接到github回购,然后它再次要求它连接到我的服务器,但它给了我一个错误的权限被拒绝(公钥)和rools回来。

看起来这是我的密钥错误,但它怎么可以连接到我的服务器来执行cap deplo:setup

我的公钥在github和我的服务器都是一样的,这是正确的?

另外当运行cap deploy:setup它问我为我的用户服务器密码是否正确?

请帮忙,因为这已经推迟了我好几天了

这是错误的:

 $ cap deploy * executing deploy' * executing deploy:update' ** transaction: start * executing `deploy:update_code' executing locally: "git ls-remote g...@github.com:rmossuk/Macrotec.git master " Enter passphrase for key '/c/Users/Rick/.ssh/id_rsa': * executing "git clone -q g...@github.com: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 g...@github.com: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 

非常感谢瑞克

Solutions Collecting From Web of "capistrano问题"

如果我将其添加到我的deploy.rb文件

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

我得到这个不同的错误

 $ 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 git@github.com:rmossuk/Macrotec.git master " Enter passphrase for key '/c/Users/Rick/.ssh/id_rsa': * executing "git clone -q git@github.com: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 

你应该在你的服务器上(你想部署的地方)安装你的git服务器的密钥。

你应该有你的密钥文件(使用chmod 600 ):

 id_rsa

 id_rsa.pub

〜/ .ssh目录(使用chmod 700 )在部署用户主页的服务器上

你可能只有在你的本地开发电脑上有这个键。

你可以添加你的部署文件钩子'setup:cold',在那里将自动上传你的本地密钥文件。

这个问题真的很老,但我在Windows 7机器上又遇到了同样的问题。 您应该将forward_agent 您的ssh密钥的位置添加到您的部署配置文件中:以下是我在config / deploy.rb中的修复:

 set :ssh_options, :forward_agent => true set :ssh_options, :keys => %w(c:/Users/USERNAME/.ssh/id_rsa) 

除此之外,最好的解决方案是在Linux环境下开发rails应用程序(并使用capistrano)。 这将避免吨这样的技巧,wordrounds,这将节省大量的时间:)

不需要使用ssh密钥访问部署库中的存储库服务器。 您可以激活SSH forward_agent,使ssh_agent跟随您从机器到机器。 要用capistrano来做到这一点,可以将这一行添加到deploy.rb文件中

ssh_options [:forward_agent] = true