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):
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
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.
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!
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
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
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.
Just realized I never followed up on this:
I fixed this by:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With