gitvisual-studio-coderemote-access

VSCode Agent forwarding not working from Windows to Linux


I have the following development setup: Windows PC (Client) connects to Linux PC (Workstation). On the Windows client I open VSCode and use the remote connection. Authentification is set up using openssh (according to https://code.visualstudio.com/docs/remote/ssh) and automatic login in VScode works.

Things do not work anymore when I want to clone a repository from Github on the workstation. If I run "Git: Clone" in VSCode, I get a "permission denied (publickey)" error. Same happens when running the command in a terminal within VSCode. I can use the same ssh agent (incl. key) however natively on Windows to clone the repo (Github authentication works with that key).

I was following the answer: https://stackoverflow.com/a/39866194/3045875 and checked through the guide: https://docs.github.com/en/authentication/connecting-to-github-with-ssh/using-ssh-agent-forwarding (I was unable to fully understand what the difference between sshd_config and ssh_config (under /etc and ~ is). Now I have sshd_config AgentForwarding enabled and not specified under ssh_config.

In a VSCode remote terminal I do see that $SSH_AUTH_SOCK is set:

$ echo $SSH_AUTH_SOCK
/run/user/1001/vscode-ssh-auth-sock-1737837

In Windows I see the agent is running:

$ Get-Service ssh-agent

Status   Name               DisplayName
------   ----               -----------
Running  ssh-agent          OpenSSH Authentication Agent

I do have ~/.ssh/config on Windows containing:

Host xxx
  HostName xxx
  User username
  ForwardAgent yes

Am I missing something?


Solution

  • I was able to fix this issue by upgrading to the latest openssh version (V9.2) on Windows by running winget install "openssh beta". Reference: https://github.com/PowerShell/Win32-OpenSSH/wiki/Install-Win32-OpenSSH