1

This error comes up a lot, but the usual method has not fixed this issue: GIT push: permission denied (public key) .

This fix has not helped me. I was able to do:

ssh -T git@github.com

... with no issue at all.

git remote -v

... also returns the correct URL with SSH pattern.

This is the third time I've tried to link to a GitHub page, so I'm not sure why I'm getting this issue only now. Is there any chance that I'm being denied access by the host of the github page? Could it somehow be a fault on their end?

I am able to pull from this branch and merge, but when I tried to push my merge conflicts, as well as some updates to the code I now receive the error (after entering the passphrase for my ssh key):

Enter passphrase for key '~/.ssh/id_rsa':
ERROR: Permission to <path>.git denied to <UserName>.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

Maybe my username is wrong? I tried setting it to my github name as well as the name returned that I am being denied as.

Thanks for any help in advance!

FlamePrinz
  • 490
  • 1
  • 5
  • 20
  • Is the remote URL something of the form: `git@github.com:/.git`? – msbit Oct 10 '18 at 06:04
  • 1
    If you can really `git pull`, then your URL and credentials can't be wrong (I think). Are you certain that the owner of the repo has given you rights to push? If you are the owner, then maybe you need to configure GitHub to allow pushing. – Tim Biegeleisen Oct 10 '18 at 06:07
  • Nope, they had not given me the rights, as I suspected! Thank you for the help! – FlamePrinz Oct 10 '18 at 16:54

1 Answers1

1

I think you simply don't have access to write to this repository.

For example:

$ git clone git@github.com:freeCodeCamp/freeCodeCamp.git
Cloning into 'freeCodeCamp'...
remote: Enumerating objects: 113, done.
remote: Counting objects: 100% (113/113), done.
remote: Compressing objects: 100% (77/77), done.
remote: Total 96160 (delta 46), reused 81 (delta 36), pack-reused 96047
Receiving objects: 100% (96160/96160), 63.21 MiB | 1.58 MiB/s, done.
Resolving deltas: 100% (57205/57205), done.
Checking connectivity... done.

$ cd freeCodeCamp

$ git checkout -b push-test
Switched to a new branch 'push-test'

$ touch push-test

$ git add push-test 

$ git commit -m push-test
[push-test 0916790] push-test
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 push-test

$ git push origin push-test 
ERROR: Permission to freeCodeCamp/freeCodeCamp.git denied to msbit.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

As @tim-biegeleisen notes, you'll have to talk to the repository owner (possibly yourself?) and get them to allow access to your user. This will be the one mentioned in the output of ssh -T git@github.com.

msbit
  • 4,152
  • 2
  • 9
  • 22