2

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?

Sala Dus
  • 45
  • 1
  • 4
  • Not an answer to your particular question, but note that if you use command-line Git, it runs an ssh on *both sides* (well, technically it runs ssh on your side, which invokes an sshd on the remote to speak ssh protocol) and then there's also Git software on *both sides*. How much of this VSRemote eliminates (by absorbing some local-side jobs into itself), I don't know; VonC's answer suggests "most or all of it". – torek Mar 20 '22 at 02:24

1 Answers1

0

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.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • As I stated in my first post: "When I use the terminal from VSC, all git authentications work fine" – Sala Dus Mar 21 '22 at 22:20
  • ssh -T github.com: "You've successfully authenticated, but GitHub does not provide shell access." from VSC terminal. – Sala Dus Mar 23 '22 at 21:04
  • @SalaDus The terminal from VSC is local, not on the remote server. That is why I requested to test from an interractive session opened on the remote server, outside of VSCode, to see if github.com does authenticate you properly there. – VonC Mar 23 '22 at 23:12
  • It's definitely not local for a SSH connection. Anyways, either way the ssh test works from VSC terminal and a separate SSH session to the server. https://imgur.com/a/j6umAlj – Sala Dus Mar 25 '22 at 23:22