microsoft / vscode-remote-release

Visual Studio Code Remote Development: Open any folder in WSL, in a Docker container, or on a remote machine using SSH and take advantage of VS Code's full feature set.
https://aka.ms/vscode-remote
Other
3.57k stars 266 forks source link

ssh-askpass.bat not found on Linux remote machine #8894

Open Boulkiess opened 11 months ago

Boulkiess commented 11 months ago

Hi, in the context of my work, I am trying to setup VS Code to use dev containers. I am new to Docker and the dev containers, and overcame numerous obstacles to end up here, but this time I think the problem comes from the Dev Containers extension.

Some precisions: machine1 is an interactive machine on which one can connect as himself, with his own username. On machine2 though, people must use shared users, or bots, which do not have passwords ; they can only connect if their SSH key is registered on machine2 and they use the right bot.

[4960336 ms] Start: Run in Host: docker version --format {{.Server.APIVersion}} [4960932 ms] Stop (596 ms): Run in Host: docker version --format {{.Server.APIVersion}} [4960935 ms] [4960936 ms] error during connect: Get http://docker.example.com/v1.24/version: command [ssh -l bot -- {hostname} docker system dial-stdio] has exited with exit status 255, please make sure the URL is valid, and Docker 18.09 or later is installed on the remote host: stderr=ssh_askpass: exec(c:\Users\{user}\.vscode\extensions\ms-vscode-remote.remote-containers-0.304.0\scripts\ssh-askpass.bat): No such file or directory ssh_askpass: exec(c:\Users\{user}\.vscode\extensions\ms-vscode-remote.remote-containers-0.304.0\scripts\ssh-askpass.bat): No such file or directory Permission denied, please try again. ssh_askpass: exec(c:\Users\{user}\.vscode\extensions\ms-vscode-remote.remote-containers-0.304.0\scripts\ssh-askpass.bat): No such file or directory Permission denied, please try again. ssh_askpass: exec(c:\Users\{user}\.vscode\extensions\ms-vscode-remote.remote-containers-0.304.0\scripts\ssh-askpass.bat): No such file or directory Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).

Steps to Reproduce:

  1. From a Cygwin x64 terminal, launch ssh-agent and ssh-add to register the SSH key used to connect to the different remote hosts that will be used here.
  2. From this same terminal, launch VS Code.
  3. Connect to machine1 with Remote-SSH; no SSH keyphrase will be prompted. On machine1, only Docker-CLI is installed. Here is the log of docker version launched on machine1.

    $ docker version Client: Docker Engine - Community Version: 23.0.2 API version: 1.42 Go version: go1.19.7 Git commit: 569dd73 Built: Mon Mar 27 16:18:54 2023 OS/Arch: linux/amd64 Context: default Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

  4. Add a DOCKER_HOST item set to ssh://bot@machine2-hostname to the docker.environment VS Code Remote setting. We now use machine2 as a Docker server. Here is the log of docker version launched on machine1 again.

    $ docker version Client: Docker Engine - Community Version: 23.0.2 API version: 1.42 Go version: go1.19.7 Git commit: 569dd73 Built: Mon Mar 27 16:18:54 2023 OS/Arch: linux/amd64 Context: default

Server: Docker Engine - Community Engine: Version: 23.0.2 API version: 1.42 (minimum version 1.12) Go version: go1.19.7 Git commit: 219f21b Built: Mon Mar 27 16:16:31 2023 OS/Arch: linux/amd64 Experimental: false containerd: Version: 1.6.19 GitCommit: 1e1ea6e986c6c86565bc33d52e34b81b3e2bc71f runc: Version: 1.1.4 GitCommit: v1.1.4-0-g5fd4c4d docker-init: Version: 0.19.0 GitCommit: de40ad0

  1. Open a project containing a .devcontainers/devcontainer.json
  2. Launch the command "Dev Containers: Reopen in Container".
  3. See the error log in the Logs section.

Does this issue occur when you try this locally?: No Does this issue occur when you try this locally and all extensions are disabled?: No

chrmarti commented 10 months ago

Are you connected to machine1 with Remote-SSH when you run the Dev Containers: Reopen in Container command? Is the workspace folder with the devcontainer.json on machine1?

Boulkiess commented 10 months ago

Hi, I am indeed connected to machine1 with Remote-SSH. The opened workspace, on machine1, contains a devcontainer/.devcontainer.json file.

chrmarti commented 10 months ago

The combination of going through Remote-SSH and setting DOCKER_HOST on the SSH server doesn't work at moment and needs investigation.

Maybe in your local SSH config you could configure machine1 as a jumpserver to connect to machine2 and then use Remote-SSH to connect to machine2 directly. From there Dev Containers should also work.

timsu92 commented 4 months ago

I'm also facing the issue not finding ssh-askpass.bat on Linux hosts, but I'm using WSL 2. I guess this might be relavent.

Machine OS: Windows 11 WSL 2 OS: Ubuntu 22.04 VSCode installed on Windows, opening a project saved in WSL. With the project opened, I'm trying to open it in devcontainer in a remote Docker.

The remote Docker is set up by adding and setting docker context, which uses ssh to connect to a remote Linux machine. I know Docker can't accept username/password, so I set it through ssh-agent by putting this into .bashrc:

function _ssh_agent {
    if [ -z "$SSH_AGENT_PID" ]; then
        eval $(ssh-agent -s)
    else
        echo "ssh-agent should be running as PID $SSH_AGENT_PID"
    fi
}

function _stop_ssh_agent {
    if [ -n "$SSH_AGENT_PID" ]; then
        eval $(ssh-agent -k)
    fi
}

if [ -z "$SSH_AGENT_PID" ]; then
    _ssh_agent > /dev/null
    ssh-add ~/.ssh/id_rsa > /dev/null
else
    echo "ssh-agent should be running as PID $SSH_AGENT_PID"
fi

trap _stop_ssh_agent EXIT

This is the log when creating dev container: (I've removed the remote user name to <remote-user-name> and removed the remote address to <remote-addr>)

[12 ms] Dev Containers 0.348.0 in VS Code 1.87.0 (019f4d1419fbc8219a181fab7892ebccf7ee29a2).
[12 ms] Start: Run: wsl -d ubuntu-22.04 -e /bin/sh -c cd '/home/tim/grpc_ts_example' && /bin/sh
[23 ms] Start: Run in host: id -un
[151 ms] tim
[151 ms] 
[152 ms] Start: Run in host:  (command -v getent >/dev/null 2>&1 && getent passwd 'tim' || grep -E '^tim|^[^:]*:[^:]*:tim:' /etc/passwd || true)
[155 ms] Start: Run in host: echo ~
[155 ms] /home/tim
[155 ms] 
[156 ms] Start: Run in host: test -x '/home/tim/.vscode-remote-containers/bin/019f4d1419fbc8219a181fab7892ebccf7ee29a2/node'
[157 ms] 
[157 ms] 
[157 ms] Start: Run in host: test -f '/home/tim/.vscode-remote-containers/dist/vscode-remote-containers-server-0.348.0.js'
[158 ms] 
[158 ms] 
[160 ms] userEnvProbe: loginInteractiveShell (default)
[160 ms] userEnvProbe: not found in cache
[160 ms] userEnvProbe shell: /usr/bin/zsh
[1777 ms] userEnvProbe PATHs:
Probe:     '/home/tim/miniconda3/condabin:/home/tim/.bun/bin:/home/tim/.zplug/repos/zplug/zplug/bin:/home/tim/.zplug/bin:/home/tim/.nvm/versions/node/v18.19.0/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/lib/wsl/lib:/mnt/c/Windows/system32:/mnt/c/Windows:/mnt/c/Windows/System32/Wbem:/mnt/c/Windows/System32/WindowsPowerShell/v1.0:/mnt/c/Windows/System32/OpenSSH:/mnt/c/Program Files (x86)/NVIDIA Corporation/PhysX/Common:/mnt/c/Program Files/NVIDIA Corporation/NVIDIA NvDLISR:/mnt/c/Program Files/Microsoft VS Code/bin:/mnt/c/Program Files/dotnet:/mnt/c/Program Files (x86)/ZeroTier/One:/mnt/c/Program Files/usbipd-win:/Docker/host/bin:/mnt/c/Users/timsu/AppData/Local/Microsoft/WindowsApps:/mnt/c/Users/timsu/Documents/which.exe:/mnt/c/Users/timsu/Documents/ffmpeg/bin:/mnt/c/Users/timsu/AppData/Local/GitHubDesktop/bin:/mnt/c/Users/timsu/AppData/Roaming/Code/User/globalStorage/ms-vscode-remote.remote-containers/cli-bin:/home/tim/.local/bin:/home/tim/.bun/bin:/snap/bin:/usr/local/cuda/bin:/usr/local/go/bin:/home/tim/.fzf/bin'
Container: None
[470937 ms] Start: Run: wsl -d ubuntu-22.04 -e /bin/sh -c cd '/home/tim/grpc_ts_example' && /bin/sh
[470952 ms] Start: Run in host: id -un
[471089 ms] tim
[471089 ms] 
[471090 ms] Start: Run in host:  (command -v getent >/dev/null 2>&1 && getent passwd 'tim' || grep -E '^tim|^[^:]*:[^:]*:tim:' /etc/passwd || true)
[471092 ms] Start: Run in host: echo ~
[471093 ms] /home/tim
[471093 ms] 
[471093 ms] Start: Run in host: test -x '/home/tim/.vscode-remote-containers/bin/019f4d1419fbc8219a181fab7892ebccf7ee29a2/node'
[471094 ms] 
[471094 ms] 
[471094 ms] Start: Run in host: test -f '/home/tim/.vscode-remote-containers/dist/vscode-remote-containers-server-0.348.0.js'
[471096 ms] 
[471096 ms] 
[471097 ms] userEnvProbe: loginInteractiveShell (default)
[471097 ms] userEnvProbe: not found in cache
[471097 ms] userEnvProbe shell: /usr/bin/zsh
[473100 ms] Start: Run in Host: /bin/sh 
[473102 ms] Start: Run in container: for pid in `cd /proc && ls -d [0-9]*`; do { echo $pid ; readlink /proc/$pid/cwd || echo ; readlink /proc/$pid/ns/mnt || echo ; cat /proc/$pid/stat | tr "
[473105 ms] userEnvProbe PATHs:
Probe:     '/home/tim/miniconda3/condabin:/home/tim/.bun/bin:/home/tim/.zplug/repos/zplug/zplug/bin:/home/tim/.zplug/bin:/home/tim/.nvm/versions/node/v18.19.0/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/lib/wsl/lib:/mnt/c/Windows/system32:/mnt/c/Windows:/mnt/c/Windows/System32/Wbem:/mnt/c/Windows/System32/WindowsPowerShell/v1.0:/mnt/c/Windows/System32/OpenSSH:/mnt/c/Program Files (x86)/NVIDIA Corporation/PhysX/Common:/mnt/c/Program Files/NVIDIA Corporation/NVIDIA NvDLISR:/mnt/c/Program Files/Microsoft VS Code/bin:/mnt/c/Program Files/dotnet:/mnt/c/Program Files (x86)/ZeroTier/One:/mnt/c/Program Files/usbipd-win:/Docker/host/bin:/mnt/c/Users/timsu/AppData/Local/Microsoft/WindowsApps:/mnt/c/Users/timsu/Documents/which.exe:/mnt/c/Users/timsu/Documents/ffmpeg/bin:/mnt/c/Users/timsu/AppData/Local/GitHubDesktop/bin:/mnt/c/Users/timsu/AppData/Roaming/Code/User/globalStorage/ms-vscode-remote.remote-containers/cli-bin:/home/tim/.local/bin:/home/tim/.bun/bin:/snap/bin:/usr/local/cuda/bin:/usr/local/go/bin:/home/tim/.fzf/bin'
Container: None
[473173 ms] Start: Run in Host: docker version --format {{json .}}
[473307 ms] userEnvProbe is taking longer than 2 seconds. Process not found.
[474701 ms] error during connect: Get "http://docker.example.com/v1.24/version": command [ssh -o ConnectTimeout=30 -l <remote-user-name> -- <remote-addr> docker system dial-stdio] has exited with exit status 255, please make sure the URL is valid, and Docker 18.09 or later is installed on the remote host: stderr=ssh_askpass: exec(c:\\Users\\timsu\\.vscode\\extensions\\ms-vscode-remote.remote-containers-0.348.0\\scripts\\ssh-askpass.bat): No such file or directory
Permission denied, please try again.
ssh_askpass: exec(c:\\Users\\timsu\\.vscode\\extensions\\ms-vscode-remote.remote-containers-0.348.0\\scripts\\ssh-askpass.bat): No such file or directory
Permission denied, please try again.
ssh_askpass: exec(c:\\Users\\timsu\\.vscode\\extensions\\ms-vscode-remote.remote-containers-0.348.0\\scripts\\ssh-askpass.bat): No such file or directory
<remote-user-name>@<remote-addr>: Permission denied (publickey,password).

[474702 ms] {"Client":{"CloudIntegration":"v1.0.35+desktop.11","Version":"25.0.3","ApiVersion":"1.44","DefaultAPIVersion":"1.44","GitCommit":"4debf41","GoVersion":"go1.21.6","Os":"linux","Arch":"amd64","BuildTime":"Tue Feb  6 21:13:00 2024","Context":"aiec"},"Server":null}
[474706 ms] Exit code 1

From the log, I noticed some things:

  1. It's trying to use askpass.bat in Windows, and the file indeed exists there. So I guess it's trying to do this in the WSL environment, which should accessing Windows files through /mnt/c/... and should execute ssh-askpass.sh
  2. In the setup guide regarding to SSH, it asks me to set docker.explorerRefreshInterval to a higher value. However, this settings doesn't seem to be exist as I can't find it in GUI settings, and putting this in settings.json shows dimmed color. As a result, we can see the response is too late in the log.

I'm sure the SSH set in WSL is correct, as running docker info shows info of remote Docker