IcyBloom
IcyBloom

Reputation: 340

How to configure VSCode to auto git fetch without asking for SSH key password on Windows 10

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].

Upvotes: 3

Views: 7525

Answers (2)

Efren
Efren

Reputation: 4907

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

Upvotes: 1

VonC
VonC

Reputation: 1328982

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

Upvotes: 1

Related Questions