使用git SSH的Composer随机停止工作

Pet*_*sen 5 git ssh bitbucket composer-php

因此,我一直在使用作曲家来管理我的git repos(在bitbucket上),现在,忧郁的作曲家抱怨我无法访问我的repos: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
)
Run Code Online (Sandbox Code Playgroud)

有什么事吗

更新资料

我只是推送到我的git仓库之一,它工作正常。因此,似乎SSH密钥已正确设置,但Composer所做的事情很奇怪。

更新2

看来,composer updatesudo(ie sudo composer update)身份运行将不会使用您的 ssh密钥……所以我必须将SSH密钥添加到我想的root用户中?:\

Von*_*onC 2

正如此BitBucket 线程中提到的:

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

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

或者您可以尝试sudo -E保护您的环境,如“ Git SSH 公钥被拒绝”中所述。