简体   繁体   English

卡皮斯特拉诺问题

[英]capistrano problem

I am having a problem with deploying my application to my server. 我将应用程序部署到服务器时遇到问题。

I have msysgit, github and capistrano installed and working. 我安装了msysgit,github和capistrano。

I have successfully pushed my app to github and can successfully run cap deploy:setup to setup on my server from my local machine. 我已成功将我的应用程序推送到github并且可以成功运行cap deploy:setup从我的本地计算机在我的服务器上进行设置。

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. 当我运行cap deploy:cold它要求我连接到github repo的密码然后它再次要求它连接到我的服务器但是然后它给了我一个错误权限被拒绝(公钥)并且回滚。

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 ? 这似乎是我的密钥错误,但它怎么能连接到我的服务器进行cap deplo:setup

My public keys are the same in both github and my server is this correct ? 我的公钥在github和我的服务器都是一样的这是正确的吗?

Also when running cap deploy:setup it asks me for my user server password is this correct ? 同样在运行cap deploy:setup它会询问我的用户服务器密码是否正确?

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 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 

Thanks alot rick 非常感谢瑞克

If I add this to my deploy.rb file 如果我将它添加到我的deploy.rb文件中

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 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

You should have on your server (where you want deploy) installed yours access keys for git server. 你应该在你的服务器(你想要部署的地方)安装你的git服务器访问密钥。

You should have yours key files (with chmod 600 ): 您应该拥有自己的密钥文件(使用chmod 600 ):

id_rsa

id_rsa.pub

in ~/.ssh directory (with chmod 700 ) on server in deploy user home 在部署用户主目录服务器上的〜/ .ssh目录(使用chmod 700 )中

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. 您可以为“setup:cold”添加部署文件挂钩,其中将自动上载您的本地密钥文件。

This question is really old, but I just encountered the same problem again on a windows 7 machine. 这个问题真的很老了,但我刚刚在Windows 7机器上遇到了同样的问题。 You should add forward_agent and the location of your ssh key to your deploy config file: Here is my fix at config/deploy.rb: 您应该将forward_agent ssh密钥的位置添加到部署配置文件中:以下是我在config / deploy.rb中的修复:

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

Besides that, the best solution would be to develop rails applications (and to use capistrano) in a linux environment. 除此之外,最好的解决方案是在linux环境中开发rails应用程序(并使用capistrano)。 This would avoid tons of such tricks, wordrounds and it would save plenty of time :) 这将避免大量的这样的技巧,wordrounds,它会节省大量的时间:)

It's not needed to have the ssh keys to access the repository server on the deploy mahcine. 不需要使用ssh密钥来访问部署mahcine上的存储库服务器。 You can activate the SSH forward_agent, to make the ssh_agent follow you from machine to mache. 您可以激活SSH forward_agent,使ssh_agent跟随您从机器到mache。 To do this with capistrano, you can add this line to the deploy.rb file 要使用capistrano执行此操作,可以将此行添加到deploy.rb文件中

ssh_options[:forward_agent] = true ssh_options [:forward_agent] = true

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM