microsoft / vscode-remote-release

Visual Studio Code Remote Development: Open any folder in WSL, in a Docker container, or on a remote machine using SSH and take advantage of VS Code's full feature set.
https://aka.ms/vscode-remote
Other
3.67k stars 289 forks source link

[Remote-SSH Bug]: Adding new host breaks ssh config file after VSCode update #10013

Open Anwarvic opened 4 months ago

Anwarvic commented 4 months ago

Is there an existing issue for this bug?

Required Troubleshooting Steps

Connect Locally

It connects successfully

Bug Description

Hi Team,

After the most recent VSCode update on 06/18/2024, whenever I add a new host using RemoteSSH, the extension addes the new host but also heavily changes the configuration file which disrupts any future connections to all servers in the configuration file. Here is the current VSCode version where this issue occurs:

Version: 1.90.2 (user setup)
Commit: 5437499feb04f7a586f677b155b039bc2b3669eb
Date: 2024-06-18T22:34:26.404Z
Electron: 29.4.0
ElectronBuildId: 9728852
Chromium: 122.0.6261.156
Node.js: 20.9.0
V8: 12.2.281.27-electron.0
OS: Windows_NT x64 10.0.22631

Kindly note that the earlier VSCode version didn't have this issue. However, I found this old issue: #6197 with similar problem.

Current Behavior

Let's assume that I have tihs configuration file:

Host TMP-3PLogs
  HostName YYYY
  IdentityFile ~/.ssh/id_rsa
  StrictHostKeyChecking no
  UserKnownHostsFile /dev/null
  ProxyCommand ssh -i ~/.ssh/id_rsa -W %h:%p -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null XXX@ZZZ
  User XXX

Now, let's add a new host using the following command in the Remote SSH + button, which basically adds the same host aleady in the configuration file (aka TMP-3PLogs).

ssh -i ~/.ssh/id_rsa -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o ProxyCommand="ssh -i ~/.ssh/id_rsa -W %h:%p -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null XXX@ZZZ" XXX@YYYY

Now, the configuration file changs to the following:

# the new host is added perfectly
Host ZZZ
  HostName YYYY
  IdentityFile ~/.ssh/id_rsa
  StrictHostKeyChecking no
  UserKnownHostsFile /dev/null
  ProxyCommand ssh -i ~/.ssh/id_rsa -W %h:%p -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null XXX@ZZZ
  User XXX

# the old configuratoin changed (see comments below)
Host TMP-3PLogs
  HostName YYYY
  IdentityFile ~/.ssh/id_rsa
  StrictHostKeyChecking no
  UserKnownHostsFile=/dev/null  # <--- `=` has been added
  ProxyCommand ssh -i ~/.ssh/id_rsa -W %h:%p -o StrictHostKeyChecking no -o UserKnownHostsFile /dev/null XXX@ZZZ # <-- all `=` have been removed
  User XXX

This nasty bug wasted two days of my life I'm not getting back 😞

roblourens commented 4 months ago

Sorry for the trouble, we did update the ssh-config parser in the last update and I'd guess this is somehow related to that. I can't repro this on Windows or mac though. Can you install the latest Remote-SSH pre-release extension and let me know if you still see it? Is there anything else in your config file besides what you posted above?

Anwarvic commented 4 months ago

Hi @roblourens ,

So sorry about the late reply! I was out-of-office the past few days. Below is some information about what you've asked :

Can you install Remote-SSH pre-release extension and let me know if you still see it [the issue]?

Yes, I've installed VSCode Insiders and Remote-SSH pre-release and still see the issue. I even recorded my screen where the issue occurs real-time.

bug-repro

Is there anything else in your config file besides what you posted above?

No. However, if the configuration file is empty, there will be no issue since this bug changes the content of already-existing hosts in the configuration file as seen in the above recording. Also, the number of hosts in the configuration flie doesn't matter. I've tried one and many and both get affected by the bug.

Hope this helps!

roblourens commented 4 months ago

Oh, I do see it removing = in the ProxyCommand. I just don't see it adding one to UserKnownHostsFile in the existing config. This is probably enough for me to investigate though.

roblourens commented 4 months ago

Filed upstream: https://github.com/cyjake/ssh-config/issues/84

QiuMP commented 3 months ago

Any update about this issue?