Git: SSH error Permission denied in WSL2 + Remote Containers
See original GitHub issueIssue Type: Bug
When using a remote container within WSL2 that has ssh-agent (in this case using keychain) setup to cache credentials I can use git fine from my terminal.
However trying to use the Source Control tools with Git results in an error:
git@my-redacted-host.com: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
There is plenty of advice/documentation prior to WSL2 but with this particular combination I can’t find any documentation.
VS Code version: Code - Insiders 1.48.0-insider (15ada625f20086007e2c4aa0d760234360cd648f, 2020-07-30T14:43:12.691Z) OS version: Windows_NT x64 10.0.19041 Remote OS version: Linux x64 4.19.104-microsoft-standard
System Info
Item | Value |
---|---|
CPUs | Intel® Core™ i7-6700 CPU @ 3.40GHz (8 x 3408) |
GPU Status | 2d_canvas: enabled flash_3d: enabled flash_stage3d: enabled flash_stage3d_baseline: enabled gpu_compositing: enabled multiple_raster_threads: enabled_on oop_rasterization: disabled_off opengl: enabled_on protected_video_decode: unavailable_off rasterization: enabled skia_renderer: disabled_off_ok video_decode: enabled vulkan: disabled_off webgl: enabled webgl2: enabled |
Load (avg) | undefined |
Memory (System) | 15.91GB (2.73GB free) |
Process Argv | |
Screen Reader | no |
VM | 0% |
Item | Value |
---|---|
Remote | Dev Container: vscode-dev-aws |
OS | Linux x64 4.19.104-microsoft-standard |
CPUs | Intel® Core™ i7-6700 CPU @ 3.40GHz (8 x 3407) |
Memory (System) | 7.77GB (0.21GB free) |
VM | 0% |
Extensions (17)
Extension | Author (truncated) | Version |
---|---|---|
remote-containers | ms- | 0.128.0 |
remote-ssh-edit-nightly | ms- | 2020.7.38340 |
remote-ssh-explorer-nightly | ms- | 2019.8.31680 |
remote-ssh-nightly | ms- | 2020.7.38340 |
remote-wsl | ms- | 0.44.4 |
aws-toolkit-vscode | ama | 1.12.0 |
vscode-markdownlint | Dav | 0.36.2 |
gitlens | eam | 10.2.2 |
gitlab-workflow | Git | 3.1.0 |
aws-cli-configure | mar | 0.3.0 |
vsliveshare | ms- | 1.0.2478 |
vsliveshare-audio | ms- | 0.1.85 |
vsliveshare-pack | ms- | 0.4.0 |
resourcemonitor | mut | 1.0.7 |
trailing-spaces | sha | 0.3.1 |
gitflow | vec | 1.2.1 |
markdown-all-in-one | yzh | 3.2.0 |
Issue Analytics
- State:
- Created 3 years ago
- Reactions:12
- Comments:13
Top Results From Across the Web
Git + SSH key issues on Windows with VSCode + WSL2 + ...
I'm on Windows 10, and am using VSCode with Docker and WSL2. For the life of me I can't get git + ssh...
Read more >Troubleshooting Windows Subsystem for Linux | Microsoft Learn
Provides detailed information about common errors and issues people run into while running Linux on the Windows Subsystem for Linux.
Read more >Remote Development FAQ - Visual Studio Code
This article covers frequently asked questions for each of the Visual Studio Code Remote Development extensions. See the SSH, Containers, and WSL articles ......
Read more >Git: git@gitlab.com: Permission denied (publickey) with VSC
... but I now get an error Git: git@gitlab.com: Permission denied (publickey). when I try to push. I went through the Generating a...
Read more >Permission denied publickey fatal Could not read from remote ...
Trying to git clone and getting the error message: Permission denied (publickey).fatal: Could not read from remote repository.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thank you @hastarin
I resolved this issue. My way is install zsh to my WSL2-Ubuntu and enable plugin ssh-agent and import my private key
zstyle :omz:plugins:ssh-agent identities id_rsa
.After all, boom! Everything is fine!
@gundamkid I did get this working again for me in a more recent version.
It involved installing the socat package under the WSL2 container. I’m afraid I can’t recall exactly where I learned I needed to do that.