【发布时间】:2019-07-12 04:06:16
【问题描述】:
Capistrano 无法通过 Windows 的 ssh 代理转发连接到 git repo (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-remote 或clone。发出 cap deploy 或 cap 任务(如 git ls-remote)时,连接到 bitbucket 存储库失败。
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 存储库。
我已经编写了上限任务来显示 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 使用了错误的公钥或未能使用代理转发。我也将所有密钥添加到 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
【问题讨论】:
标签: git ssh capistrano openssh