vscode icon indicating copy to clipboard operation
vscode copied to clipboard

VSCode does not retrieve SSH passphrase from kwallet/ksshaskpass

Open Rua opened this issue 9 months ago • 8 comments

Does this issue occur when all extensions are disabled?: Yes

  • VS Code Version: 1.97.2 (not installed via flatpak)
  • OS Version: Fedora 41 with KDE 6.3 / NixOS 24.11 with KDE 6.2

ssh-agent is automatically started on boot. I have SSH set up to use kwallet via ksshaskpass:

$ echo $SSH_ASKPASS
/usr/bin/ksshaskpass
$ echo $SSH_ASKPASS_REQUIRE 
prefer

My SSH key uses a passphrase. If I go to a Git repository and do git pull on the terminal, then if the passphrase is already in kwallet, it will immediately perform the operation. Otherwise, the ksshaskpass window pops up to ask for the passphrase. It asks for the passphrase only once, and remembers it even after a restart.

In VSCode, however, if I use the GUI to pull from the same repo, then I get a popup asking me for the passphrase. I can fill it in and it works, but each time I perform a Git operation, it asks me again. It does not remember the passphrase at all, not even within the same session. I can, however, run git pull or whatever in the terminal within VSCode, and that works. Only the VSCode GUI doesn't store/retrieve the passphrase.

If I run ssh-add, then run VSCode, then VSCode will successfully retrieve the passphrase and will not prompt for it. But that only lasts for the current boot, it will not remember after a restart.

Rua avatar Mar 03 '25 18:03 Rua

What is the current value of the following settings:

  • git.useIntegratedAskPass
  • git.terminalAuthentication

lszomoru avatar Mar 18 '25 10:03 lszomoru

What is the current value of the following settings:

* `git.useIntegratedAskPass`

* `git.terminalAuthentication`
"git.useIntegratedAskPass": true,
"git.terminalAuthentication": true,

Rua avatar Mar 18 '25 18:03 Rua

If I run ssh-add, then run VSCode, then VSCode will successfully retrieve the passphrase and will not prompt for it. But that only lasts for the current boot, it will not remember after a restart.

This seems to indicate that the problem is specific to your local configuration. I would suggest that you go through the documentation from here - https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent#adding-your-ssh-key-to-the-ssh-agent. Please note the following section of the documentation:

If you continue to be prompted for your passphrase, you may need to add the command to your ~/.zshrc file (or your ~/.bashrc file for bash).

lszomoru avatar Apr 09 '25 13:04 lszomoru

When I run Git from the terminal, it never needs the key from the SSH agent. It will directly retrieve it from ksshaskpass. So it works without ever doing ssh-add. VSCode on the other hand will only work if I do ssh-add. That does not seem like a configuration problem to me, since one program can retrieve the key but not the other. Unless VSCode is specifically made to work differently from regular Git in this situation?

Rua avatar Apr 09 '25 14:04 Rua

I solved this by setting the GIT_ASKPASS environment variable and setting git.useIntegratedAskPass to false, as mentioned in this comment.

zyllian avatar Apr 12 '25 18:04 zyllian

Hey @lszomoru, this issue might need further attention.

@Rua, you can help us out by closing this issue if the problem no longer exists, or adding more information.

I solved this by setting the GIT_ASKPASS environment variable and setting git.useIntegratedAskPass to false, as mentioned in this comment.

That seems to have fixed it for me! But it seems like a workaround; can the built-in askpass not be fixed?

Rua avatar Jul 09 '25 12:07 Rua

Hey @lszomoru, this issue might need further attention.

@Rua, you can help us out by closing this issue if the problem no longer exists, or adding more information.