Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git: ERROR: Permission to repo.git denied to user

Tags:

github

ubuntu

I'm unable to push (but pull works fine) to my company's git repository over both HTTPS and SSH, and would really appreciate any help on this. It's a similar issue to the one seen here: (Git's famous "ERROR: Permission to .git denied to user") except that I'm pushing to a company repo rather than a personal repo -- wondering if this might have something to do with a company firewall.

Here's what I've done (after already cloning the repo):

Over SSH:

git remote set-url origin [SSH url of my company repo]

Set up my ssh key and added it to my user account; ssh to [email protected] gives me permission denied (publickey), but ssh to [email protected] authenticates succesfully.

git pull
git push origin master

Which gives me:

ERROR: Permission to Organization/repo.git denied to user. fatal: The remote end hung up unexpectedly

Over HTTPS:

git remote set-url origin [HTTPS url of my company repo]
git pull
git push origin master

Which prompts me for username and password and then gives me:

error: Cannot access URL [HTTPS url of my company repo], return code 22 fatal: git-http-push failed

Here are the contents of my .git/config:

[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[remote "origin"]
fetch = +refs/heads/*:refs/remotes/origin/*
url = [HTTPS url of my company repo]
[branch "master"]
remote = origin
merge = refs/heads/master

I've confirmed that I've been added as a collaborator to the organization. Removing myself and getting re-added hasn't fixed the problem, and neither has deleting my ssh keys and generating new ones and adding them to my account. I also tried deleting my entire user account and setting up from scratch, which solved this problem once before, but it doesn't seem to work now and produces the same errors.

One thing is, this problem occurred initially when I set up my git access to the repo, and I solved it by deleting my user account and setting up again. For the next 2 months I was able to successfully push to the repo over HTTPS without a problem. These errors showed up again after a team member set up their access and pushed some code; could this be a source of the problem?

If anyone can help me out, I would be eternally grateful.

like image 212
ayluo Avatar asked Aug 15 '13 01:08

ayluo


People also ask

How do I fix remote permission to repo git denied Ubuntu?

Always use the "git" user $ ssh -T [email protected] > Permission denied (publickey). If your connection failed and you're using a remote URL with your GitHub username, you can change the remote URL to use the "git" user. You should verify your connection by typing: $ ssh -T [email protected] > Hi username!


3 Answers

This error occurs because of collision of github user account's, which means maybe someone else had access his github account and by mistake saved his password with your github details.

Now every time you try to push into a repo the github faces collision.

So the solution is. if you are a mac user

  1. Open your launchpad and search keychain access.
  2. Now remove your github credentials from keychain account.
  3. Push to your repo and add your account details.

For other System Try using the Keychain Access application instead:

https://help.github.com/articles/updating-credentials-from-the-osx-keychain/#updating-your-credentials-via-keychain-access

like image 138
Anup Panwar Avatar answered Oct 04 '22 07:10

Anup Panwar


How many other people are using this repo? From your description, it looks like everyone uses the same ssh user name. It could just be how you anonymized the URL, but if everyone uses the same user name, then there is probably one authorized_keys list ssh uses to determine which keys are valid. When the new user was added, your ssh key might have gotten replaced, deleted, or omitted from the authorized keys list on the server.

like image 39
wrdieter Avatar answered Oct 04 '22 05:10

wrdieter


Just realized I never followed up on this:

I fixed this by:

  • logging in under a teammate's credentials,
  • deleting, and
  • re-adding myself as an owner of the repo.
like image 45
ayluo Avatar answered Oct 04 '22 07:10

ayluo