【问题标题】:Composer with git SSH stopped working randomly带有 git SSH 的 Composer 随机停止工作
【发布时间】:2014-05-17 18:00:44
【问题描述】:

所以,我一直在使用 composer 来管理我的 git 存储库(在 bitbucket 上),现在,作曲家突然抱怨我无法访问我的存储库:S

我没有做任何特别的事情。但我继续使用 ssh-keygen 生成了一个新密钥,复制了公钥并将其添加到我的 bitbucket 帐户中。

于是我又试了sudo composer update,还是报错:

Failed to update git@bitbucket.org:afflicto/event.git, package information from this repository may be outdated (Agent admitted failure to sign using the key.
Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
error: Could not fetch origin
)

可能出了什么问题?

更新

我刚刚推送到我的一个 git 存储库,它工作正常。所以看起来 SSH 密钥设置正确,但 Composer 正在做一些奇怪的事情。

更新 2

似乎以sudo(即sudo composer update)运行composer update 不会使用你的 ssh 密钥...所以我想我必须将我的SSH 密钥添加到root 用户? :\

【问题讨论】:

    标签: git ssh composer-php bitbucket


    【解决方案1】:

    正如BitBucket thread中提到的:

    使用sudo ssh 将在/home/username/.ssh/ 中查找root 的密钥,而不是您的密钥。
    您可能不应该使用 sudo 运行 git。

    但是,如果您确实需要,请在 root 帐户下生成一些新密钥并将其上传到 Bitbucket。

    或者您可以尝试sudo -E,以保护您的环境,如“Git SSH public key denied”中所述。

    【讨论】:

    • 我最终也为 root 创建了一个 ssh 密钥,是的。 sudo -E 不过,这很好!
    【解决方案2】:

    就我而言,我有第二个 ssh 密钥,需要将其添加为 ssh-agent 中的身份

    1. eval $(ssh-agent -s)
    2. ssh-add ~/.ssh/my_ssh_private_key

    【讨论】:

      猜你喜欢
      • 2014-04-11
      • 2014-09-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-10-14
      相关资源
      最近更新 更多