简体   繁体   中英

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

I've quite an extensive .ssh/config file with entries such as:

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. Now when I use this setup within VSCode it seems like the container doesn't know about the config file. 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. So the ssh-agent is forwarded to the container, but not the config file. 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/gitlab

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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