Ruby on rails 卡皮斯特拉诺问题

Ruby on rails 卡皮斯特拉诺问题,ruby-on-rails,windows,git,deployment,capistrano,Ruby On Rails,Windows,Git,Deployment,Capistrano,我在将应用程序部署到服务器时遇到问题 我已经安装了msysgit、github和capistrano并开始工作 我已成功将我的应用程序推送到github,并且可以成功运行 cap deploy:setup从本地计算机在我的服务器上安装 但是 当我运行cap deploy:cold时,它会询问我要连接的密码短语 github repo然后它再次要求它连接到我的服务器,但是 给我一个错误权限被拒绝(公钥)并返回 看来这是我钥匙的错误,但怎么可能呢 连接到我的服务器以执行cap deplo:setup

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

我已经安装了msysgit、github和capistrano并开始工作

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

但是

当我运行
cap deploy:cold
时,它会询问我要连接的密码短语 github repo然后它再次要求它连接到我的服务器,但是 给我一个错误权限被拒绝(公钥)并返回

看来这是我钥匙的错误,但怎么可能呢 连接到我的服务器以执行
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 

非常感谢rick,你应该在你的服务器(你想要部署的地方)上安装你的git服务器访问密钥

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

id_rsa id_rsa.pub 在部署用户主页的服务器上的~/.ssh目录中(使用chmod 700

您可能只有本地开发计算机上才有该密钥

您可以为“setup:cold”添加部署文件钩子,其中将自动
上载本地密钥文件

如果我将其添加到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

不需要ssh密钥就可以访问deploy mahcine上的存储库服务器。您可以激活SSH转发代理,使SSH代理跟随您从机器到机器。要使用capistrano执行此操作,可以将此行添加到deploy.rb文件中

set :ssh_options, {:forward_agent => true}
on :start do    
  `ssh-add`
end
ssh_选项[:转发_代理]=真


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

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

除此之外,最好的解决方案是在linux环境中开发rails应用程序(并使用capistrano)。这将避免大量此类恶作剧,节省大量时间:)

为什么您在我的本地计算机和服务器上都有公钥和私钥?这些应该完全相同吗?我以为你只是在本地机器上有公共-私有,然后把pulic复制到服务器上?问题是我可以用sshuser@server然后输入我的密码,它将以这种方式连接到服务器???您希望使用git部署,capistrano不希望从服务器端而不是从您的计算机上获取代码,这就是为什么您应该在服务器帐户上拥有git访问密钥的原因。您必须将ssh从您的计算机访问服务器的权限和从服务器访问git服务器的权限分开(以获取最后的源代码)。您不需要从本地计算机上载源,而是通过服务器端的git请求部署。理论上,capistrano支持ssh代理,这样就可以使用本地密钥,而不需要在部署服务器上使用自己的密钥。事实上,这是理想的情况。然而,capistrano似乎在这一特性上有点破绽