'VS Code on Windows - git push results in Permission Denied (publickey)

Running VS Code 1.0.0 on Windows, trying to push to bitbucket using SSH auth.

Issue is similar to: To use <git push> on Visual Studio Code, but show "Could not read from remote repository."

However, in my case the credentials in /User/profile/.ssh are already on my bitbucket account and if I CTRL+SHIFT+P, CTRL+SHIFT+C everything works fine in the windows cli.

Actually, it seems every other method I've tried seems to pick up those credentials such as git gui and other gui tools. VS Code seems to be the only outlier.

Which credentials is VS Code attempting to use? Is that configurable?

Edit: Using Process Monitor to look for access to key files during fetch/pull/push from Code only seems to show /User/profile/.ssh/id_rsa getting looked up, which is the correct key.

I would expect VS Code to prompt for credentials after trying to use that key, but, still get Permission Denied (publickey)



Solution 1:[1]

Here are the things you should try:

  1. Restart the VS code

  2. Verify that you are using the git:// protocol

  3. close the VS code and restart the ssh-agent:

     $ eval "$(ssh-agent -s)"
    
  4. Now verify that the key is actually loaded:

     ssh-add -l
    
  5. Generate a new pair of keys as described in the answer you attached and use them.


I would expect VS Code to prompt for credentials after trying to use that key

I you have credentials (using https for example) run this command:

git config --global credential.helper cache
// OR: 
git config --global credential.helper store

cache
Cache credentials in memory for a short period of time. See git-credential-cache[1] for details.

store
Store credentials indefinitely on disk. See git-credential-store[1] for details.

Solution 2:[2]

Necromancing this question because I had trouble solving it.

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

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 BioGeek
Solution 2 Roger