如何让 VSCode Remote Container 读取 ssh 配置文件?

How to make VSCode Remote Container read the ssh config file?

我有一个相当大的 .ssh/config 文件,其中包含以下条目:

Host gitlab.com
    Preferredauthentications publickey
    HostName gitlab.com
    User git
    IdentityFile ~/.ssh/gitlab.pub
    IdentitiesOnly yes

我还使用 SSH 代理来提供私钥。现在,当我在 VSCode 中使用此设置时,容器似乎不知道配置文件。我 运行 遇到如下错误:

Received disconnect from 172.65.251.78 port 22:2: Too many authentication failures
Disconnected from 172.65.251.78 port 22
fatal: Could not read from remote repository.

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

通过在容器中 运行ning GIT_SSH_COMMAND="ssh -v" git fetch,我发现所有密钥都已尝试,并且在尝试 5 次后 Gitlab SSH 服务器不想继续。所以 ssh-agent 被转发到容器,而不是配置文件。在容器外一切正常。

有人对此有解决方案吗?

我的环境:

Version: 1.53.0
Commit: 8490d3dde47c57ba65ec40dd192d014fd2113496
Date: 2021-02-03T15:56:04.185Z
Electron: 11.2.1
Chrome: 87.0.4280.141
Node.js: 12.18.3
V8: 8.7.220.31-electron.0
OS: Linux x64 5.10.13-arch1-2

Remote-Containers: v0.158.0
 IdentityFile ~/.ssh/gitlab.pub

这似乎是错误的:通常,IdentityFile 引用 private SSH 密钥,而不是 public:

IdentityFile ~/.ssh/gitlab