vscode: Linux ssh-agent/ssh-askpass problem

As already reported in #33814, #32097, #52137 the bug isn’t fixed for me and the workarounds don’t work either

VSCode Version: 1.26.1
OS Version: Ubuntu 16.04
Date: 2018-08-16T18:34:20.517Z
Electron: 2.0.5
Chrome: 61.0.3163.100
Node.js: 8.9.3
V8: 6.1.534.41
Architecture: x64
Shell: zsh

Steps to Reproduce:

  1. Open a Git repo folder
  2. Call a Git action like sync, push etc

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

I’m using ssh-agent to keep all my keys opened and enter the passwords after I boot (ssh-add ~/.ssh/id_rsa). I can use git from the terminal without any problems, but “use the terminal then” is not a valid workaround for me when a whole feature doesn’t work. I’ve set some configs in my ~/.ssh/config file as well

Host *
  ServerAliveInterval 60
  AddKeysToAgent yes
  IdentityFile ~/.ssh/id_rsa
Host gitlab.com
  HostName gitlab.com
  User git
Host github.com
  HostName github.com
  User git

But it still get this error when using a feature that calls a remote git action:

> git pull --tags origin master
ssh_askpass: exec(/usr/bin/ssh-askpass): No such file or directory
Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists

I already tried installing ssh-askpass with sudo apt-get install ssh-askpass-gnome ssh-askpass but he asks me every single time for a password, so the ssh-agent is ignored

About this issue

  • Original URL
  • State: open
  • Created 6 years ago
  • Reactions: 11
  • Comments: 32 (7 by maintainers)

Most upvoted comments

Hello i had same problems with Code - OSS on Manjaro

Version : 1.44.2 Validation : ff915844119ce9485abfe8aa9076ec76b5300ddd Date : 2020-04-23T19:32:05.786Z Électron : 7.1.14 Chrome : 78.0.3904.130 Node.js : 12.8.1 V8 : 7.8.279.23-electron.0 OS : Linux x64 5.4.40-1-MANJARO

I use Manjaro with KDE and he provide ksshaskpass i have simply create a symbolic link to his binary with and it’s work sudo ln -s /usr/bin/ksshaskpass /usr/lib/ssh/ssh-askpass

Screenshot_20200529_221133

I also tried openssh-askpass sudo ln -s /usr/bin/qt4-ssh-askpass /usr/lib/ssh/ssh-askpass

They are cool because may integrate better into the desktop environments.

In my tests only x11-ssh-askpass automatically create “/usr/lib/ssh/ssh-askpass”

Look the packages in your distribution i think you can find same packages

But i don’t understand why VSCode could not use ssh-agent to not ask password at each push/pull maybe an other bug because i haven’t this problems on windows

In our screen sharing session we figured out what was happening:

@derN3rd uses i3 with rofi. He launches code from rofi, which finds executables in the PATH. Code sets up the CLI launcher executable in the PATH, so rofi picks that one up. This is problematic since we never expected the CLI launcher executable to be launched in a non-shell environment, i.e. window managers. So, the CLI launcher behaves as if it was in a shell environment and doesn’t run our getUnixShellEnvironment . The result is a Code instance which never got the chance to execute (in this case) .zshrc. So, the SSH agent is improperly configured.

For a fix, we need to have a better way for whatever process we put in the PATH to detect whether it is already in an environment which was populated with the user’s RC files (whether it is a descendant of a shell process).

Found a solution. I’m using ArchLinux KDE + KWallet/ksshaskpass.

My /etc/environment:

GIT_ASKPASS=ksshaskpass
SSH_ASKPASS=ksshaskpass
SSH_ASKPASS_REQUIRE=prefer

Disable VSCode’s built-in askpass:

{
	"git.useIntegratedAskPass": false
}

It should work now 😃

Was this fixed then or is there a workaround? I have the same issue, using i3 with j4-dmenu-desktop

I’m on manjaro + i3wm and using gnome-keyring to manage my SSH keys, and I managed to stop vscode always ask password/use openssh askpass by putting the follwing line in my ~/.profile and rebooting (must be .profile as .bashrc is not executed by dmenu when opening another program):

export SSH_AUTH_SOCK=$XDG_RUNTIME_DIR/gcr/ssh

I took some hints from @joaomoreno’s comment above: https://github.com/microsoft/vscode/issues/57488#issuecomment-417259290. In the context of KDE Plasma, I now run code with a global shortcut that runs konsole -e code. This runs the app in a terminal but the terminal flashes up and disappears. The app then has access to the ssh-agent as per a regular bash terminal session. I imagine there would be similar approaches for other DEs/WMs.

I also recommend using @sebtiz13’s approach in https://github.com/microsoft/vscode/issues/57488#issuecomment-636184685 as one cannot copy and paste a password into the x11-ssh-askpass prompt.

I encountered this problem on a recent (Aug. 2022) install of Arch with KDE. I setup my ~/.config/systemd/user/ssh-agent.service, ~/.config/environment.d/ssh_askpass.conf and ~/.config/autostart/ssh-add.desktop as documented in the Arch Wiki for KWallet to work.

git and code work as expected when run in a Konsole window. Like others, I’ll use konsole -e code as a workaround.

When I poked around the vscode processes environment variables, it appears SSH_AUTH_SOCK is not set, so perhaps this is an interaction between the ssh-agent service, KDE, and vscode.

Is that a commad @joaomoreno that you meantioned? Because if it is then it doesn’t exist on mine. (noob)

pranav@Exam:~$ ssh-askpass-gnome
ssh-askpass-gnome: command not found

In Ubuntu 19.10 I have same kindof issue. Screenshot from 2019-12-13 14-31-40