Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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)

like image 902
MrMeek Avatar asked Oct 30 '22 04:10

MrMeek


1 Answers

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.

like image 78
CodeWizard Avatar answered Nov 15 '22 05:11

CodeWizard