Composer with git SSH stopped working randomly
Asked Answered
R

3

8

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 [email protected]: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? :\

Randalrandall answered 5/4, 2014 at 10:12 Comment(0)
D
2

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".

Desouza answered 5/4, 2014 at 10:48 Comment(1)
I ended up creating an ssh key for root as well yeah. sudo -E though, that's neat!Randalrandall
A
0

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
Aggrieved answered 19/12, 2018 at 16:46 Comment(0)
H
0

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)

Harm answered 26/4, 2023 at 7:19 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.