我将应用程序部署到服务器时遇到问题。
我安装并运行了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
答案 0 :(得分: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
答案 1 :(得分:1)
您应该在您的服务器(您要部署的地方)安装了您的git服务器访问密钥。
您应该拥有自己的密钥文件(使用 chmod 600 ):
id_rsa id_rsa.pub在部署用户主页的服务器上的〜/ .ssh 目录中( chmod 700 )
您可能只在本地开发计算机上拥有该密钥。
您可以为“setup:cold”添加部署文件挂钩,其中将自动执行 上传您的本地密钥文件。
答案 2 :(得分:1)
这个问题真的很老了,但我刚刚在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)。这样可以避免大量的伎俩,字谜,这样可以节省大量的时间:)
答案 3 :(得分:-1)
不需要使用ssh密钥来访问部署mahcine上的存储库服务器。您可以激活SSH forward_agent,使ssh_agent跟随您从机器到mache。要使用capistrano执行此操作,可以将此行添加到deploy.rb文件
ssh_options [:forward_agent] = true