3

Because of this password prompt, auto-fetch, push and pull from VSCode doesn't work. This requires me to manually push/pull from the integrated terminal (which will prompt me a password).

However, when I run ssh -T [email protected] within the Integrated Terminal of VSCode, I am able to ssh in without a password prompt (which is what I am trying to achieve). I have already added the ssh keys via ssh-add and I see them using ssh-add -L. Similarly, I am able to run ssh -T [email protected] in Windows Terminal without being prompted for the password.

What I wish to achieve is being able to push and pull my repositories using VSCode's inbuilt tools without the password prompt every time I attempt to fetch, pull or push. This password prompt is preventing VSCode from auto-fetching or updating my repository by clicking the sync icon on the bottom right (results in a Permission denied(publickey, keyboard-interactive) prompt from VSCode)

Edit:

Thanks to VonC, I don't have to type my password everytime I run git fetch etc. within VSCode's integrated terminal. This was solved by adding

$env:GIT_SSH="C:\Windows\System32\OpenSSH\ssh.exe"

to my Powershell profile.

However, it still didn't resolve the main issue that VSCode's internal source control tools are unable to pull from [email protected] but keeps trying at [email protected].

2 Answers 2

1

Make sure the remote origin URL used by VSCode is actually github.com-work (check that in the VSCode output terminal for 'Git').
You don't even need git if your %USERPROFILE%\.ssh\config file does specify User git under the entry Host github.com-work)

And as mentioned here, launch VSCode (for testing) from a CMD where you have:

set GIT_SSH=C:\Windows\System32\OpenSSH\ssh.exe
Sign up to request clarification or add additional context in comments.

7 Comments

Hmm from VSCode output I can't really see the actual remote origin URL. All I see is ``` > git remote --verbose > git config --get commit.template > git fetch ``` however, I can verify on the side (I have Gitlens installed) that the remote is indeed github.com-work. However, it seems that VSCode is unable to understand that and keeps trying to pull from github.com instead
@IcyBloom That is what I though. In command line, go to your local cloned repo, and type git remote -v to check.
Yeapp I just checked it and origins are both [email protected] for both fetch and push
@IcyBloom Maybe that is VSCode translating your ssh config file. Or it actually uses another local repository path?
Hmm I don't think there is another local repository that can be used, and I have ensured that all my ssh config files are the same. :( Plus, through the integrated terminal it is able to git fetch and pull from the right remote, just not through the internal tools (that will output to the readonly terminal)
|
1

These extra steps did the trick: ref

The key is to use Windows' OpenSSH as mentioned, but also need to setup git config file to load the key in the Windows Agent.

    AddKeysToAgent yes
    IdentitiesOnly yes

1 Comment

Tested restarting VSCODE only, not sure yet what happens after restarting windows

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.