简体   繁体   中英

VS Code gives me an ssh_askpass error when I try to push the changes to my Github repository using the integrated git

I have this problem, I've created a Github repository to back up a project. I have normal SSH access to my repo from my Linux command line and I can push, pull, commit, sync and all that stuff with no problem. But when I try to use the VS Code github integration tool to push my changes it gives me this error:

Git: ssh_askpass: exec(usr/lib/ssh/ssh_askpass): No such file or directory.

I've looked for this file on the mentioned directory but all I've seen was a file named gassh_askpass.

I'm currently using Manjaro and VS Code 1.28.2

If depends also on your OS.

For instance, Microsoft/vscode/issue 32097 illustrates various MacOS workarounds::

In my case, it's caused by updating of mac OS, makes git lose passphrase of my ssh key.
After ssh-add ~/.ssh/id_rsa , and REINSTALL vscode, this problem is fixed.

Or:

 $ brew tap theseal/ssh-askpass $ brew install ssh-askpass $ sudo ln -s /usr/local/bin/ssh-askpass /usr/X11R6/bin/ssh-askpass

Or :

  • Download xQuartz latest version : https://www.xquartz.org
  • update and upgrade home-brew via 'brew update && brew upgrade'
  • link: $ sudo ln -s /usr/local/bin/ssh-askpass /usr/X11R6/bin/ssh-askpass as @stargriv described above :-)
  • Start VSCode, should work now
  • You still have to type in your password every time when you connect to the server; if you don't want that, create a ssh-key file.

The OP Prabesh Bhattarai references " ' ssh_askpass exec(/usr/libexec/openssh/ssh-askpass) no such file or directory ' error when I try to push in Git repo using VS Code "

If you use services like SSH keys, make sure you don't disable SSH Key Agent. It was a stupid mistake

If the SSH-agent is disabled, it cannot register the passphrase indeed.

I had to do 2 things to get this solved.

  1. Install ssh_askpass

     sudo apt install ssh-askpass
  2. Use this command to add bitbucket.org (In my case it was Bitbucket)

     ssh-keyscan -t rsa bitbucket.org >> ~/.ssh/known_hosts

I had this problem after upgrading to MacOS Big Sur. Some of the options from VonC's answer worked for me, but in a slightly different combination. These were my steps to finally get VS Code working together with GitHub again:

1. (Re-)install ssh-askpass & start ssh-pass service

As the docs state: :

brew install theseal/ssh-askpass/ssh-askpass

Or if you already had it installed (like me), then re-install:

brew reinstall theseal/ssh-askpass/ssh-askpass

Finally start the ssh-askpass service to load the SSH_ASKPASS environment variable via:

brew services start ssh-askpass

2. Prepare to create symbolic link to ssh-askpass (aka install xQuartz)

I simply wanted to create a symbolic link from /usr/local/bin/ssh-askpass to /usr/X11R6/bin/ssh-askpass . But I realized that in MacOS Big Sur the file /usr/X11R6 itself is a link to /private/var/select/X11 and that inside /private/var/select the X11 is simply gone . Trying to access it I got a cd: no such file or directory: /private/var/select/X11 .

This can be fixed by installing the latest version of XQuartz from https://www.xquartz.org . Download the XQuartz-2.xxdmg , open it and follow the installation steps. Afterwards the folder /private/var/select/X11 is present again :)

3. Create symbolic link to ssh-askpass

Now we'll be able to create the symbolic link:

sudo ln -s /usr/local/bin/ssh-askpass /usr/X11R6/bin/ssh-askpass

4. Allow VS Code to access Systems Events in MacOS System Preferences

Using the GitHub integration in VSCode will only work, as we allow it to access System Events.app which itself is needed to interact with ssh-askpass . This can be configured in the MacOS System Preferences / Security & Privacy windows inside the Privacy tab. You may need to scroll down to the Automation point and check the box for Code (sorry I have only a German MacOS here):

vscode-隐私-自动化-系统-事件-设置

5. Re-Start or even Re-Install VSCode

For me only re-starting VS Code didn't fix the problem. After having done all the steps mentioned above another error with ssh-askpass made it into my VS Code log: /usr/local/bin/ssh-askpass:2141:2142: execution error: „System Events“ error connection invalid (-2700)

As I also used homebrew to install VSCode I simply ran

brew reinstall visual-studio-code

to re-install it. Finally the GitHub integration worked again for me.

6. (Optional, only if your ssh key has a passphrase) Add your ssh key's passphrase to the MacOS keychain

If you created a ssh key which is secured by a passphrase, VS Code might ask you for that passphrase every time you use the Git integration (which was the case for me). If you don't want to type the passphrase every time, there was also a hint by VonC in the comments of his answer: you need to add the key's passphrase to the MacOS keychain (which is described in the GitHub docs ).

Here is a brief summary what you need to do:

6.1 Enhance your ~/.ssh/config

Add the 3 lines to your ~/.ssh/config using your ssh key's name:

Host *
  AddKeysToAgent yes
  UseKeychain yes
  IdentityFile ~/.ssh/your_key_file_name_here

6.2 Add your passphrase to the MacOS keychain

Run the ssh-add command using the -K parameter:

ssh-add -K ~/.ssh/your_key_file_name_here

Now your VS Code should stop asking for your key's passphrase!

For monjaro Users, you can isntall openssh askpass:

pacman -S openssh-askpass

This will open a plasma-like passphrase dialog for ssh in VScode when you tried to pull and push to github. This works for Monjaro.

如果您使用 Arch KDE 并使用 ksshaskpass,您可以符号链接到 VSCode 要求的位置。

sudo ln -s /usr/bin/ksshaskpass /usr/lib/ssh/ssh-askpass

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM