Pergunta

So, I've been using composer to manage my git repos (on bitbucket) and now, out of the blue composer complains about me not having access to my repos :S

I haven't done anything in particular. But I went ahead and generated a new key using ssh-keygen, copied the public key and added it to my bitbucket account.

So I tried sudo composer update again, and it still complains:

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
)

What could be wrong?

Update

I just pushed to one of my git repos, and it works fine. So it seems the SSH Key is setup correctly but Composer is doing something strange.

Update 2

It seems that running composer update as sudo (i.e sudo composer update) will not use your ssh keys... so I have to add my SSH keys to the root user I suppose? :\

Foi útil?

Solução

As mentioned in this BitBucket thread:

By using sudo ssh will look for root's keys, not yours in /home/username/.ssh/.
You probably shouldn't be running git with sudo.

But if you really need to, generate some new keys under the root account and upload those to Bitbucket.

Or you can try sudo -E, to preserve your environment, as mentioned in "Git SSH public key denied".

Outras dicas

In my case, I had a 2nd ssh key and needed to add it as an identity in ssh-agent

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

In my case, the problem was that my SSH keys had permission 0777 so composer ignored them. I discovered it by running in verbose mode (composer update -vvv)

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top