我正在努力配置Capistrano 3.1以部署托管在Github上的应用程序.
我正在关注Capistrano文档,我已成功完成第一步(从工作站到服务器的SSH密钥)和第二步(从我们的服务器到存储库主机)我能够成功运行ssh -A deploy@one-of-my-servers.com 'git ls-remote git@github.com:my_user/my_repo.git'
:
18f38afz261df35d462f7f4e2ca847d22f148a06 HEAD 18f38afz261df35d462f7f4e2ca847d22f148a06 refs/heads/master
然而,ssh deploy@one-of-my-servers.com 'git ls-remote git@github.com:my_user/my_repo.git'
失败了:
Permission denied (publickey).
Capistrano医生建议
如果您收到错误"主机密钥验证失败".登录到您的服务器并以部署用户ssh git@github.com命令运行,将github.com添加到已知主机列表中.
所以,我试过但是我明白了
ssh git@github.com Warning: Permanently added the RSA host key for IP address '192.30.252.131' to the list of known hosts. Permission denied (publickey).
我基本上无法成功访问Github仓库.
SSH文档说明:
-A Enables forwarding of the authentication agent connection. This can also be specified on a per-host basis in a configuration file.
如何在配置文件中基于每个主机指定?
我的本地机器运行Mac OSX Mavericks.VPS运行Ubuntu 12.04
谢谢.
您是否已将ssh密钥添加到代理标识列表中?
您可以查看ssh-add -L
,您应该看到用于连接到github的密钥:
$ ssh-add -L ssh-rsa AAAAB3N.....0VmSiRvTzBrbU0ww== /Users/youruser/.ssh/id_rsa
如果您没有看到用于github的ssh密钥或类似的消息
代理没有身份.
然后你应该添加你的密钥:
ssh-add ~/.ssh/id_rsa
(替换为您用于github的密钥的路径)
有关详细信息,请参阅ssh-add doc
将以下内容添加到〜/ .ssh/config
Host one-of-my-servers.com ForwardAgent yes
将以下行添加到本地计算机上的.ssh/config文件中
Host Server_Address ForwardAgent yes
检查您的本地密钥是否列在ssh-add列表中
ssh-add -L
如果没有为SSH代理添加密钥
ssh-add -K
连接到远程服务器
ssh -v username@Server_Address
检查SSH代理转发是否通过运行以下命令启用.它应该列出一个套接字文件
echo "$SSH_AUTH_SOCK"
对GitHub运行连接测试
ssh -T git@github.com
针对目标git存储库运行ls远程测试
git ls-remote --heads git@github.com:account/repo.git
最后从本地计算机注销并运行以下命令
cap production git:check