Visual Studio Code Remote Edit git authentication issue

Viewed 330

I've been pulling my hair out with this for a while now.

Running Visual Studio Code (1.65.2) on Windows 10.

So I have a remote SSH connection to a linux machine, on which I have directory, which is a git repository and is synced to Github.

Whenever I try to use the Visual Studio Codes' sync button, I get the following error.

[2022-03-19T17:29:29.276Z] > git pull --tags origin new-time-management [787ms]
[2022-03-19T17:29:29.276Z] git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.

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

From the Output of VSC, I can see that it seems to be using the git on the Remote host, since this is the git version the Remote host runs, but my local machine uses a newer one:

[2022-03-19T17:46:55.585Z] Validating found git in: git
[2022-03-19T17:46:55.624Z] Using git 2.25.1 from git

Which is kind of confusing, since all guidance I've read so far seems to hint that I should be changing my ~/.ssh/config & referring to keys on my local machine. Anyways, I configured everything correctly there just in case, but does not seem to help.

My ~/.ssh/config:

Host github.com
  User git
  Hostname github.com
  IdentityFile ~/.ssh/github_private_key.ppk
  AddKeysToAgent yes

When I use the terminal from VSC, all git authentications work fine, since it's probably basically just an ssh connection to the remote host.

Also all the local (inside remote-ssh) git functionality works fine.

I tried using all the guides I found, but none worked so far. For example: this and this.

I'm probably missing some fundamental understanding of how this is supposed to work. Is it supposed to run the git on the remote host or local, when using Remote-SSH?

1 Answers

Is it supposed to run the git on the remote host or local, when using Remote-SSH?

On the remote host, where the push/pull is supposed to happen.

That means you should open an interactive ssh session (outside of VSCode) to that server, and check a ssh -Tv github.com works (meaning: "ends with a 'Hi username! You've successfully authenticated, but GitHub does not provide shell access.'")

The idea is to check/debug from command line (on the remote host) first: once that is working, chances are the VSCode Remote SSH session will benefit from the same working commands.

Related