Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Composer with git SSH stopped working randomly

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? :\

like image 804
Petter Thowsen Avatar asked Apr 05 '14 10:04

Petter Thowsen


1 Answers

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

like image 137
VonC Avatar answered Sep 30 '22 03:09

VonC