Windows ssh 代理转发和 cap\git 部署问题

Windows ssh agent forwarding and cap\git deploy problems

Capistrano 无法使用来自 windows.

的 ssh 代理转发连接到 git 存储库(bitbucket)

环境:

Windows 10
Ruby 2.4.4 for Windows installed
Rails 5.2.2
Cap 3.11.0
OpenSSH_for_Windows_7.7p1

可以成功通过 ssh 连接到主机和 git ls-remoteclone。当发出 cap 部署或 cap 任务时 git ls-remote 连接到 bitbucket repo 失败。

git stdout: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
git stderr: Nothing written

如果使用 http 并在 URL 中设置 username:password,Capistrano 会连接到 bitbucket 存储库。

我已经写了 cap 任务来显示 SSH_AUTH_SOCK 已设置。我玩过 .ssh\config,有许多指向键的选项,host *

deploy.rb:

set :repo_url 设置正确。

staging.rb

set :ssh_options,
    keys: ['c:\users\mike\.ssh\key.pem'],
    forward_agent: true

.ssh\config

Host hostname
  User username
  IdentityFile ~/.ssh/key.pem
  ForwardAgent yes

/etc/ssh/sshd.conf 在服务器上

AllowAgentForwarding yes

正在寻求有关下一步尝试的建议。似乎 cap 使用了错误的 public 密钥或未能使用代理转发。我也已将所有密钥添加到 bitbucket,但没有用。

其他发现:

在上限部署期间监控 /var/log/secure 产生此

似乎无法连接到源计算机上的 ssh-agent。

Feb 18 23:13:15 ip-255-255-255-255 sshd[19242]: Accepted publickey for railsuser from x.x.x.x port 60682 ssh2: RSA SHA256:<has>
Feb 18 23:13:15 ip-255-255-255-255 sshd[19242]: pam_unix(sshd:session): session opened for user railsuser by (uid=0)
Feb 18 23:13:15 ip-255-255-255-255 sshd[19260]: channel 2: open failed: connect failed: could not connect to authentication agent
Feb 18 23:13:15 ip-255-255-255-255 sshd[19242]: pam_unix(sshd:session): session closed for user railsuser

Capistrano 使用 net-ssh gem 并且 net-ssh 当前不支持 Windows OpenSSH 的本机安装。

Net-ssh 支持 Putty's pageant or Cygwin's ssh-agent 安装。

我已经成功地测试了 Putty 的选美,它按预期工作。