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
。发出上限git ls-remote
之类的上限部署或上限任务时,连接到位桶存储库失败。
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,但这没用。
在cap部署期间监视/ 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
答案 0 :(得分:0)
Capistrano使用net-ssh gem,并且net-ssh当前不支持Windows本机安装的OpenSSH。
Net-ssh确实支持Putty's pageant或Cygwin's ssh-agent安装。
我已经成功测试了Putty的选美比赛,并且按预期工作。