5

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)

Community
  • 1
  • 1
MrMeek
  • 71
  • 1
  • 1
  • 7
  • Do you have the SSH keys under /User/profile/.ssh directory? and have you added the public SSH key to your bitbucket account? – RaviTezu May 08 '16 at 18:06
  • Yes, the keys in /User/myprofile/.ssh are on my bitbucket account. Everything works fine from git bash, windows cli, git gui, etc, etc – MrMeek May 08 '16 at 18:09
  • I would say this is due to VS Code not picking up on the SSH_AUTH_SOCK environment variable, see [my answer here](https://stackoverflow.com/a/72029153/308451) for the full explanation. – JBSnorro Apr 27 '22 at 14:28

2 Answers2

2

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.

BioGeek
  • 21,897
  • 23
  • 83
  • 145
CodeWizard
  • 128,036
  • 21
  • 144
  • 167
1

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

Roger
  • 2,684
  • 4
  • 36
  • 51