2

I keep running into an issue when I try to pull or push to my remote repository from VS Code. Every time that I do, I get the error: "Permission Denied: (Public Key)".

The log tells me:

git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights and the repository exists.

Jared Ross
  • 77
  • 2
  • 8
  • add your ssh public key to github and make sure you are an owner or collaborator to the repository you are trying to push to. – iamcaleberic Jan 27 '18 at 22:06
  • 1
    Possible duplicate of [Git - Permission denied (publickey)](https://stackoverflow.com/questions/2643502/git-permission-denied-publickey) – phd Jan 27 '18 at 22:40
  • 1
    @iamcaleberic I have added my public key to github and can push via my terminal. I cannot push from VS Code. – Jared Ross Jan 27 '18 at 23:06
  • @JaredRoss could you configure git again on your VS integrated terminal and see how that goes... – iamcaleberic Jan 27 '18 at 23:20
  • "Deleting" the project in VS Code might help (not deleting the files) and then reopen the project. (In order to get rid of internal project dependent configuration on the VS Code side) – LinFelix Jan 28 '18 at 02:12

2 Answers2

1

Check first if your ssh key is passphrase-protected and what your OS is.

If you are on Mac, the passphrase might be in the keychain, in which case, see if issue 36818 applies: it references Saving SSH keys in macOS Sierra keychain.

Try again, for testing, with regenerating default public/private SSH keys without passphrase.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
1

For me it helped to change protocol from ssh to https: git remote set-url origin https://github.com/username/ProjectName.git

Roger
  • 2,684
  • 4
  • 36
  • 51