Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 762
Gabe Avatar asked Oct 19 '18 04:10

Gabe


3 Answers

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.x.x.dmg, 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-privacy-automation-system-events-setting

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!

like image 183
jonashackt Avatar answered Nov 18 '22 06:11

jonashackt


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
    
like image 9
Anton Perera Avatar answered Nov 18 '22 07:11

Anton Perera


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.

For manjaro specifically, as mentioned in this thread:

If you are using Virt-Manager to connect to a remote hypervisor over SSH, you need to install openssh-askpass as well as x11-ssh-askpass

sudo pacman -S openssh-askpass x11-ssh-askpass

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.

like image 7
VonC Avatar answered Nov 18 '22 07:11

VonC