githubvisual-studio-codesshgit-clonevscode-remote-ssh

VS Code: I can Git Clone in VS Code terminal (Bash) using SSH but get permission denied (public key) in VS Code Source Control


I really need some help here. I am stuck trying to use the Source Control option in VS Code to clone a few git repositories. I can successfully clone them onto my C: drive via the bash terminal in VS Code using SSH without any issues. I run the following:

eval $(ssh-agent -s)
ssh-add C:/my/file/path/private_key
ssh-add -l
ssh-T git@github.com
git clone git@github.com/the_repository

All of these commands work, with the expected results. Sure enough, I get the repositories in the target location. Can also Git Push. No issues at all.

However, when I try to git clone the exact same repositions using the VS Code UI option select "Source Code" > "Open Folder" > "Provide repo URL" > navigate to the folder in my C: Drive as the target location, I get the following error:

Permission denied (publickey)
fatal: Could not read from remote directory

I have tried EVERYTHING. Help from colleagues, ChatGPT walkthrough, other Stack Overflow tickets, etc. I know my key pairs are working since I can clone via the VSCode terminal but cannot figure out why I can't do the same with using the VS Code UI. I tried updating my config file, but that doesn't seem to make any difference. I have all of the required extensions (remote-ssh, etc.). I am convinced it has something to do with my VS Code configuration on my local machine but can't figure it out.

Anyone else come across this? Thanks in advance


Solution

  • I suspect the bash terminal is using the [bash_home]/.ssh folder and VS Code is using C:\Users\your.username\.ssh

    Add the same .ssh folder and files in C:\Users\your.username\.ssh