3

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

我已经安装并运行了 msysgit、github 和 capistrano。

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

但..

当我运行cap deploy:cold它时,它要求我输入密码以连接到 github 存储库,然后它再次要求它连接到我的服务器,但随后它给了我一个错误权限被拒绝(公钥)并返回。

似乎这是我的密钥错误,但它如何连接到我的服务器来执行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 

非常感谢瑞克

4

4 回答 4

4

如果我将此添加到我的 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
于 2009-07-24T11:30:35.570 回答
1

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

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

id_rsa

id_rsa.pub

~/.ssh目录(使用chmod 700)中部署用户主目录中的服务器

您可能仅在本地开发计算机上拥有该密钥。

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

于 2009-07-24T10:19:43.730 回答
1

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

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

除此之外,最好的解决方案是在 linux 环境中开发 rails 应用程序(并使用 capistrano)。这样可以避免大量此类技巧,单词回合,并且可以节省大量时间:)

于 2013-01-21T15:45:28.377 回答
-1

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

ssh_options[:forward_agent] = true

于 2011-09-30T11:14:13.493 回答