Skip to content

remote - containers with Docker Desktop not forwarding ssh-agent from Git for Windows #6719

@amurzeau

Description

@amurzeau
  • VSCode Version: 1.63.2 or 1.67.1 (same behavior and errors for both)
  • Local OS Version: Windows 10 Entreprise 1809 17763.1935
  • Remote OS Version: Docker Desktop 2.1.7.0 / engine 19.03.5 (with HyperV)
  • Remote Extension/Connection Type: Remote - Containers 0.209.6 and 0.234.0 (same behavior and errors for both)
  • Git for Windows 2.23.0, ssh version OpenSSH_8.0p1, OpenSSL 1.1.1c 28 May 2019
  • Logs:

Start script in git bash: ssh-agent sh -c 'ssh-add ~/.ssh/id_rsa; ./code.exe'

Log of ssh-add -l in powershell (local command to check that SSH_AUTH_SOCK and ssh are working, key content replaced with 0s):

PS C:\Users\user> ssh-add -l
3072 SHA256:trq++00000000000000000000000000000000000000 user@host (RSA)

Starting a devcontainer using Docker Desktop give this message:

[17741 ms] Start: Launching Remote-Containers helper.
[17741 ms] ssh-agent: SSH_AUTH_SOCK in container (/tmp/vscode-ssh-auth-b40f9ddddb69d8c4a063d651337d9b53229c20df.sock) forwarded to local host (C:/Users/user/AppData/Local/Temp/ssh-EXqkeSdl9JlB/agent.2428).

C:/Users/user/AppData/Local/Temp/ssh-EXqkeSdl9JlB/agent.2428 match the SSH_AUTH_SOCK set by ssh-agent.

When trying to ssh-add -l in a terminal inside the devcontainer, I get this error:

root@86b574330cde:/workspaces/repository# ssh-add -l    
error fetching identities: communication with agent failed

And at the same time, the devcontainer logs shows this:

[50200 ms] Container server: Remote to local stream terminated with error: {
  message: 'Socket is closed',
  name: 'Error',
  stack: 'Error [ERR_SOCKET_CLOSED]: Socket is closed\n' +
    '\tat Socket._writeGeneric (net.js:775:8)\n' +
    '\tat Socket._write (net.js:797:8)\n' +
    '\tat writeOrBuffer (internal/streams/writable.js:358:12)\n' +
    '\tat Socket.Writable.write (internal/streams/writable.js:303:10)\n' +
    '\tat c:\\VSCode\\data\\extensions\\ms-vscode-remote.remote-containers-0.209.5\\dist\\extension\\extension.js:16:4913\n' +
    '\tat source (c:\\VSCode\\data\\extensions\\ms-vscode-remote.remote-containers-0.209.5\\dist\\extension\\extension.js:11:22821)\n' +
    '\tat c:\\VSCode\\data\\extensions\\ms-vscode-remote.remote-containers-0.209.5\\dist\\extension\\extension.js:16:4763\n' +
    '\tat e (c:\\VSCode\\data\\extensions\\ms-vscode-remote.remote-containers-0.209.5\\dist\\extension\\extension.js:11:13646)\n' +
    '\tat SI.exports (c:\\VSCode\\data\\extensions\\ms-vscode-remote.remote-containers-0.209.5\\dist\\extension\\extension.js:11:13695)\n' +
    '\tat c:\\VSCode\\data\\extensions\\ms-vscode-remote.remote-containers-0.209.5\\dist\\extension\\extension.js:16:4748\n' +
    '\tat processTicksAndRejections (internal/process/task_queues.js:75:11)'
}

Steps to Reproduce:

  1. Have a SSH key as ~/.ssh/id_rsa in Git bash for Windows
  2. Start Code.exe from a git bash console using ssh-agent sh -c 'ssh-add ~/.ssh/id_rsa; ./code.exe'
  3. Check that the ssh-agent is working correctly using the Powershell terminal in VSCode and running ssh-add -l, it shows the added key
  4. Open a devcontainer with a Docker Desktop container
  5. Open the terminal and run ssh-add -l

I expect Git for Windows' ssh-agent to be forwarded inside the devcontainer as it is with Powershell OpenSSH Win32 ssh-agent.
I can't use the later because the ssh-agent Windows' service is disabled by the enterprise and I don't have admin rights to change that.

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

Metadata

Metadata

Assignees

Labels

bugIssue identified by VS Code Team member as probable bugcontainersIssue in vscode-remote containers

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions