windows 上的 Capistrano 部署失败并显示 git

Capistrano deploy on windows fails with git

我正在尝试使用 git bash 在 windows 机器上进行部署。 下面是我的 staging.rb 文件。

set :stage, :staging
set :chruby_ruby, '2.2'
set :rails_env, :staging

#set :branch, '15_inaccurate-line-on-map'
set :branch, 'staging'

set :ssh_options, {
    forward_agent: true
}

set :rvm_roles, [:some]
set :rvm_map_bins, []

server 'XX.XX.XX.XX', user: 'deploy', roles: %w(web app db)

存储库在 bitbucket 上。我在 bitbucket 和服务器上添加了我的密钥。 所以当我尝试 bash.

时,这些命令成功了
ssh deploy@XX.XX.XX.XX

ssh -A deploy@xx.xx.xx.xx 'git ls-remote --heads git@bitbucket.org:<user>/<repo>.git'

git pull origin staging

问题是我在尝试 cap staging deploy

时在 git:check 上看到错误
INFO [548342cf] Running /usr/bin/env mkdir -p /tmp/butlermaps/ as deploy@xx.xx.xx.xx
INFO [548342cf] Finished in 3.145 seconds with exit status 0 (successful).
INFO Uploading /tmp/butlermaps/git-ssh.sh 100.0%
INFO [2f19d649] Running /usr/bin/env chmod +x /tmp/butlermaps/git-ssh.sh as depl
oy@xx.xx.xx.xx
INFO [2f19d649] Finished in 0.487 seconds with exit status 0 (successful).
** Execute git:check
INFO [61e3a414] Running /usr/bin/env git ls-remote --heads git@bitbucket.org:<user>/<repo>.git
 as deploy@xx.xx.xx.xx
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing as deploy@xx.xx.xx.xx:
git exit status: 128
git stdout: Nothing written
git stderr: Error reading response length from authentication socket.
conq: repository access denied.
fatal: The remote end hung up unexpectedly
c:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/sshkit-1.7.1/lib/sshkit/runners/parallel.
rb:16:in `rescue in block (2 levels) in execute'
c:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/sshkit-1.7.1/lib/sshkit/runners/parallel.
rb:12:in `block (2 levels) in execute'
SSHKit::Command::Failed: git exit status: 128
git stdout: Nothing written
git stderr: Error reading response length from authentication socket.
conq: repository access denied.
fatal: The remote end hung up unexpectedly
c:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/sshkit-1.7.1/lib/sshkit/command.rb:95:in
`exit_status='
c:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/sshkit-1.7.1/lib/sshkit/backends/netssh.r
b:179:in `block in _execute'
c:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/sshkit-1.7.1/lib/sshkit/backends/netssh.r
b:133:in `tap'
c:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/sshkit-1.7.1/lib/sshkit/backends/netssh.r
b:133:in `_execute'
c:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/sshkit-1.7.1/lib/sshkit/backends/netssh.r
b:66:in `execute'
c:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/capistrano-3.4.0/lib/capistrano/git.rb:11
:in `git'
c:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/capistrano-3.4.0/lib/capistrano/git.rb:21
:in `check'
c:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/capistrano-3.4.0/lib/capistrano/tasks/git
.rake:28:in `block (4 levels) in <top (required)>'
c:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/sshkit-1.7.1/lib/sshkit/backends/abstract
.rb:85:in `with'
c:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/capistrano-3.4.0/lib/capistrano/tasks/git
.rake:27:in `block (3 levels) in <top (required)>'
c:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/sshkit-1.7.1/lib/sshkit/backends/netssh.r
b:54:in `instance_exec'
c:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/sshkit-1.7.1/lib/sshkit/backends/netssh.r
b:54:in `run'
c:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/sshkit-1.7.1/lib/sshkit/runners/parallel.
rb:13:in `block (2 levels) in execute'
Tasks: TOP => git:check
The deploy has failed with an error: Exception while executing as deploy@xx.xx.xx.xx: 
git exit status: 128
git stdout: Nothing written
git stderr: Error reading response length from authentication socket.
conq: repository access denied.
fatal: The remote end hung up unexpectedly
** Invoke deploy:failed (first_time)
** Execute deploy:failed

有人知道为什么它在 git:check 上失败了吗?

感谢任何形式的帮助。

所以您的问题实际上是部署服务器 git 权限。部署服务器无法进入存储库,因为它的 public 密钥作为个人密钥添加到之前有权访问存储库但最近被撤销的帐户之一,因此部署服务器访问权也被撤销。

这是一个谜,但为什么 cap staging deploy 仍然为另一个开发者(我)工作。可能是因为我有 oh-my-zsh,它正在做一些神奇的事情,将我的 ssh 密钥代理到暂存服务器。

实际上,我发现这个问题是你在谷歌上搜索我试图为另一个开发人员设置部署的错误消息,这很有趣。

所以一般的解决方案是:将您的部署服务器帐户添加到存储库的 'deployment keys',伙计们!不是个人钥匙。