【发布时间】:2017-11-18 21:14:50
【问题描述】:
我正在尝试使用 Capistrano 3.x 进行部署。
我在我的 ~/.ssh/config 文件中配置了代理转发:
Host git-codecommit.*.amazonaws.com
Hostname xxxx
ForwardAgent yes
IdentityFile /path/to/codecommit_rsa
我也为与ForwardAgent yes 的服务器连接做了同样的事情。
我在 /etc/ssh/sshd_config 文件中验证了我的服务器也允许代理转发:
AllowAgentForwarding yes
INFO ----------------------------------------------------------------
INFO START 2017-11-18 16:09:44 -0500 cap production deploy
INFO ---------------------------------------------------------------------------
INFO [b43ed70f] Running /usr/bin/env mkdir -p /tmp as deploy@50.116.2.15
DEBUG [b43ed70f] Command: /usr/bin/env mkdir -p /tmp
INFO [b43ed70f] Finished in 1.132 seconds with exit status 0 (successful).
DEBUG Uploading /tmp/git-ssh-testapp-production-blankman.sh 0.0%
INFO Uploading /tmp/git-ssh-testapp-production-blankman.sh 100.0%
INFO [b1a90dc1] Running /usr/bin/env chmod 700 /tmp/git-ssh-testapp-production-blankman.sh as deploy@50.116.2.15
DEBUG [b1a90dc1] Command: /usr/bin/env chmod 700 /tmp/git-ssh-testapp-production-blankman.sh
INFO [b1a90dc1] Finished in 0.265 seconds with exit status 0 (successful).
INFO [b323707d] Running /usr/bin/env git ls-remote ssh://git-codecommit.us-east-1.amazonaws.com/v1/repos/fuweb HEAD as deploy@50.116.2.15
DEBUG [b323707d] Command: ( export GIT_ASKPASS="/bin/echo" GIT_SSH="/tmp/git-ssh-testapp-production-blankman.sh" ; /usr/bin/env git ls-remote ssh://git-codecommit.us-east-1.amazonaws.com/v1/repos/fuweb HEAD )
DEBUG [b323707d] Permission denied (publickey).
DEBUG [b323707d] fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
我在这里错过了什么?
【问题讨论】:
-
如果我错了,请纠正我:看起来部署过程已成功连接到您的服务器,但无法通过 CodeCommit 进行身份验证。您是否已经为 CodeCommit add your public key to the IAM user?
-
@CyRossignol 是的,在我的笔记本电脑上,我可以很好地连接到代码提交。
-
您是否在本地和远程服务器上都启动了 SSH 代理进程,并在本地机器上启动了
ssh-add密钥?并不是要让您厌烦这些基础知识,但我不能仅通过查看问题来假设这些先决条件:) -
@CyRossignol 是的,我做了 ssh-add。如何在远程服务器上启动它以及如何检查它是否正在运行?实际上它必须正在运行,因为我可以 'ssh deploy@1.1.1.1 并且我可以很好地进入远程服务器。
-
代理 (
ssh-agent) 与 SSH 服务器 (sshd) 不同。服务器接受连接,而(可选)代理管理凭据。登录服务器后,我们可以运行env | grep SSH来判断代理是否在运行。寻找像SSH_AGENT_PID或SSH_AGENT_SOCK这样的变量。有些系统会在登录时自动启动代理。如果没有启动,我们可以使用eval "$(ssh-agent)"在服务器上启动代理。
标签: ruby-on-rails ssh capistrano