简体   繁体   English

如何让 VSCode 远程容器读取 ssh 配置文件?

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

I've quite an extensive .ssh/config file with entries such as:我有一个相当广泛的.ssh/config文件,其中包含以下条目:

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

I also use the SSH Agent to provide the private keys.我还使用 SSH 代理来提供私钥。 Now when I use this setup within VSCode it seems like the container doesn't know about the config file.现在,当我在 VSCode 中使用此设置时,容器似乎不知道配置文件。 I run into errors like:我遇到如下错误:

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.

By running GIT_SSH_COMMAND="ssh -v" git fetch in the container, I've found out, that all keys are tried and after 5 tries the Gitlab SSH Server don't want to continue.通过在容器中运行GIT_SSH_COMMAND="ssh -v" git fetch ,我发现所有密钥都已尝试过,并且在尝试 5 次后 Gitlab Z765553E6C7AC8592C389ACt9878 想要继续服务器。 So the ssh-agent is forwarded to the container, but not the config file.所以 ssh-agent 被转发到容器,而不是配置文件。 Outside of the container everything works smoothly.在容器外,一切正常。

Does anybody has a solution for this?有人对此有解决方案吗?

My environment:我的环境:

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

That seems wrong: normally, an IdentityFile references the private SSH key, not the public one:这似乎是错误的:通常,IdentityFile 引用私有SSH 密钥,而不是公共密钥:

IdentityFile ~/.ssh/gitlab

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM