首页 > 解决方案 > Capistrano 无法让 git 工作

问题描述

我添加了一个 deploy.pub 密钥以在 github 存储库上部署密钥,但由于某种原因cap <env> deploy给了我这个错误。当我在服务器上时,我也无法克隆 repo,我收到权限错误。如果我在服务器上 ssh-add 我的密钥,那么我可以克隆,但在cap <env> deploy本地运行会创建一个新连接,并且密钥不再在钥匙串中。我错过了什么?

*** LOCAL GEMS ***
capistrano (3.4.0)

deploy.rb 包含:

set :ssh_options, {
  forward_agent: true,
  auth_methods: %w[publickey],
  keys: %w[~/.ssh/my_local_rsa]
 }

错误:

帽子流产了!

SSHKit::Runner::ExecuteError:以 deploy@server.com 执行时出现异常:git 退出状态:128

git stdout:没有写

git stderr:权限被拒绝(公钥)。

致命:无法从远程存储库中读取。

标签: gitcapistrano3

解决方案


当我将以下内容添加到我的~/.ssh/config

Host mydomain.com
  ForwardAgent yes

我也跑了ssh-add ~/.ssh/my_local_rsa


推荐阅读