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

使用git SSH的Composer随机停止工作,git,ssh,composer-php,bitbucket,Git,Ssh,Composer Php,Bitbucket,所以,我一直在使用composer管理我的git回购(在bitbucket上),现在,composer突然抱怨我无法访问我的回购:S 我没有做任何特别的事。但我继续使用ssh-keygen生成了一个新密钥,复制了公钥并将其添加到我的bitbucket帐户中 因此我再次尝试了sudo composer update,但它仍然抱怨: Failed to update git@bitbucket.org:afflicto/event.git, package information from this

所以,我一直在使用composer管理我的git回购(在bitbucket上),现在,composer突然抱怨我无法访问我的回购: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密钥添加到根用户,我想是吧\

如本文所述:

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

但是,如果确实需要,可以在
root
帐户下生成一些新密钥,并将它们上载到Bitbucket


或者您可以尝试
sudo-E
,以保护您的环境,如“.”

在我的情况下,我有第二个ssh密钥,需要将其作为身份添加到ssh代理中

  • eval$(ssh代理-s)
  • ssh添加~/.ssh/my\u ssh\u私钥

  • 我最终也为root用户创建了一个ssh密钥<代码>sudo-E不过,这很好!