flathub / com.visualstudio.code

https://flathub.org/apps/details/com.visualstudio.code
149 stars 67 forks source link

Git integration: ssh_askpass not found #23

Open ghost opened 6 years ago

ghost commented 6 years ago

CC from the Microsoft/vscode repo CC from the flathub/flathub repo

Issue Type

Bug

Description

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



### Please note

- Error **not reproducible** in `gnome-terminal` (external)
- From global config: `"terminal.integrated.shell.linux": "/bin/bash"`
- Error **not reproducible** in integrated terminal (at least I get a prompt there to input my passphrase for my SSH key)
- SSH key is unlocked, so if I run `git pull` from `gnome-terminal` (external), I do not need to enter the passphrase
- In the integrated terminal I get asked for the passphrase for each command,  so VS Code obviously cannot access the unlocked SSH keys (maybe because of the sandbox? I don't know if this can even be addressed...)
- In the integrated terminal, I do not have access to the commands `ssh-add` or similar. I thought I could just add the SSH key in the terminal to unlock it at least in the sandbox, but to no avail

### Expected behaviour

- I expect the same behaviour as in the `.deb` release where I do not need to unlock the keys and it "just works" out of the box

### VS Code Info

VS Code version: Code 1.20.1 (f88bbf9137d24d36d968ea6b2911786bfe103002, 2018-02-13T15:31:21.019Z)
OS version: Debian Stretch (Kernel: Linux x64 4.9.0-5-amd64)

<details>
<summary>System Info</summary>

|Item|Value|
|---|---|
|CPUs|Intel(R) Core(TM) i7-4710HQ CPU @ 2.50GHz (8 x 3284)|
|Load (avg)|0, 0, 0|
|Memory (System)|15.59GB (0.24GB free) (`htop` says more than 11GB free)|
|Process Argv|/app/extra/vscode/code --extensions-dir=/home/usr/.var/app/com.visualstudio.code/data/vscode/extensions --reuse-window|
|Screen Reader|no|
|VM|0%|

</details><details><summary>Extensions (1)</summary>

Extension|Author (truncated)|Version
---|---|---
python|ms-|2018.1.0

</details>
Reproduces without extensions
nedrichards commented 6 years ago

Hmmm, yeah, this sounds like they're hardcoding a path to the ssh binary which just doesn't exist from inside the flatpak. But even then - we could look and making sure that the polkit UI and connection are enabled. I'll have a think and a poke.

beniwtv commented 6 years ago

I also ran into this issue, hopefully this can be resolved somehow.

mzabaluev commented 6 years ago

Visual Studio code has its own askpass solution, shame if the runtime-provided git cannot be made to work with it. I can see some sockets inside the sandbox (thanks to the other problem, of built-in terminal running the shell inside the sandbox, not in the host system):

/run/user/1000/vscode-git-askpass-213927448c6480816cfd7551a049bb08424bc375.sock
/run/user/1000/vscode-git-askpass-3f24fb52fb77f1e6b8f6edb39a9d3661cf160897.sock
/run/user/1000/vscode-git-askpass-45e45f95784ba32bdf9f25f2259ca9156753e1d5.sock

The implementation is likely in /app/extra/vscode/resources/app/extensions/git/out/askpass*. I don't have more time for poking at the moment.

ghost commented 6 years ago

I don't know if this is of any help, but I remember that on Windows (at least in TortoiseGit) there was an option to explicitly set the SSH executable. This way you're able to use an ssh binary or, for instance, Pageant as key provider. Maybe this is a Git setting and you could make use of it to have it use the built-in VS code provider.

Edit: Apparently it is an environment variable. Look here for instance. However my knowledge is to limited to assess if this helps. Any way - thank you for looking at this.

kiview commented 6 years ago

I'm getting a similar error in a KDE environment:

ssh_askpass: exec(/usr/bin/ksshaskpass): 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.
zerodayz commented 5 years ago

@beniwtv @kiview Try workaround to run the flatpak with access to ssh-auth socket (you just need to ssh-add your ssh-key first)

$ flatpak run --socket=ssh-auth com.visualstudio.code.oss

rodber commented 5 years ago

If helps, I had this issue using the snap version. Had to uninstall it and ended up using the .deb package.

HackerTon commented 4 years ago

Quick solution: Install using .deb package as mentioned by @rodolfoberrios.

ramesh45345 commented 3 years ago

Some observations here. In the linked obsidian ticket, they mention checking the SSH_AUTH_SOCK variable. The vscode terminal prints the following information:

sh-5.1$ printenv SSH_AUTH_SOCK
/run/flatpak/ssh-auth

There are also other sockets (presumably created by vscode), and they exist at the /run/user/1000 location in my machine:

sh-5.1$ ls -la /run/user/1000/
total 0
drwx------ 2 user user 260 Jul 15 20:05 .
drwxr-xr-x 3 user user  60 Jul 15 20:05 ..
lrwxrwxrwx 1 user user  17 Jul 15 19:51 app -> ../../flatpak/app
lrwxrwxrwx 1 user user  17 Jul 15 19:51 bus -> ../../flatpak/bus
lrwxrwxrwx 1 user user  17 Jul 15 19:51 doc -> ../../flatpak/doc
lrwxrwxrwx 1 user user  22 Jul 15 19:51 .flatpak -> ../../flatpak/.flatpak
lrwxrwxrwx 1 user user  22 Jul 15 19:51 flatpak-info -> ../../../.flatpak-info
lrwxrwxrwx 1 user user  21 Jul 15 19:51 p11-kit -> ../../flatpak/p11-kit
lrwxrwxrwx 1 user user  19 Jul 15 19:51 pulse -> ../../flatpak/pulse
srwxr-xr-x 1 user user   0 Jul 15 20:05 vscode-e3c348a2-1.57.1-main.sock
srwxr-xr-x 1 user user   0 Jul 15 19:53 vscode-git-269d264186.sock
srwxr-xr-x 1 user user   0 Jul 15 19:51 vscode-git-51350bc256.sock
srwxr-xr-x 1 user user   0 Jul 15 20:05 vscode-git-59bd0e7f69.sock

When I set the SSH_AUTH_SOCK variable to the latest socket in that folder, I got the following output:

sh-5.1$ SSH_AUTH_SOCK=/run/user/1000/vscode-git-59bd0e7f69.sock 
sh-5.1$ cd gitrepo
sh-5.1$ git pull
The authenticity of host 'github.com (140.82.114.3)' can't be established.
RSA key fingerprint is
This key is not known by any other names
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added 'github.com' (RSA) to the list of known hosts.
Already up to date.

The git command works from the command line, and the actions in the GUI work. This gets reset on the next load of vscode though. Unfortunately, this is the limit of what I could figure out.

Is there some way to have the environment variable get set to the vscode socket that is generated, or vscode use the socket at the default path of /run/flatpak/ssh-auth? That would very likely solve the problem.

ramesh45345 commented 3 years ago

Side note, I forgot that this was the closed source version of Visual Studio Code. I checked the OSS version of vscode on flathub, and it has a patch which fixes this issue (https://github.com/flathub/com.visualstudio.code-oss/blob/38acf605bf3c4d8a306472e6fc4cd763d523df66/patches/ipc-sockets-paths-flatpak.patch#L9). There's no way to fix this using this method in this variant of vscode.

Basically, the only way to fix this will be to change the environment variable somehow. A workaround is to use the com.visualstudio.code-oss flatpak, where this seems to be fixed via a patch to the ipc code.