microsoft / microsoft/vscode-remote-release

HostName expansion in ssh_config with Host * pattern breaks remote ssh for matching hosts

Open
#11,067 4 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

ssh
Dominant language
Dockerfile
Stars
4.2k
Forks
470
Avg merge
1d 1h
Merged PRs (30d)
1

Description

Is there an existing issue for this bug?
  • I have searched the existing open issues and found none that apply.
  • If I find any issue of interest that is related or closed, I will included a link to it in this issue.
Required Troubleshooting Steps
  • I have read and performed the troubleshooting steps
  • I have tried both values of the remote.SSH.useLocalServer setting
  • My issue was not covered in the Tips and Tricks linked from the Troubleshooting Wiki.
  • I will include a complete copy of my Remote - SSH logs by running Remote-SSH: Show Log in the command palette or from View > Output in the menu bar
[Optional] Diagnose with Copilot

I asked @remote-ssh but it did not help

In step 2 of the troubleshooting wiki, what was the result of running the generated SSH command verbatim outside of VS Code?

I could NOT successfully SSH to the remote machine, and the error was the SAME to what I saw in VS Code

Remote-SSH Log
Remote-SSH Log

[21:23:11.121] Log Level: 2
[21:23:11.125] SSH Resolver called for "ssh-remote+7b22686f73744e616d65223a226c6461733035222c2275736572223a226a6b6c65656d616e6e227d", attempt 1
[21:23:11.128] remote.SSH.useLocalServer = false
[21:23:11.129] remote.SSH.useExecServer = true
[21:23:11.129] remote.SSH.bindHost = {}
[21:23:11.129] remote.SSH.showLoginTerminal = false
[21:23:11.129] remote.SSH.remotePlatform = {"pi":"linux","srv01":"linux"}
[21:23:11.129] remote.SSH.path = 
[21:23:11.129] remote.SSH.configFile = C:\Users\jkleemann\Linux\ssh_config.conf
[21:23:11.129] remote.SSH.useFlock = true
[21:23:11.129] remote.SSH.lockfilesInTmp = false
[21:23:11.129] remote.SSH.localServerDownload = auto
[21:23:11.129] remote.SSH.remoteServerListenOnSocket = false
[21:23:11.130] remote.SSH.defaultExtensions = []
[21:23:11.130] remote.SSH.defaultExtensionsIfInstalledLocally = []
[21:23:11.130] remote.SSH.loglevel = 2
[21:23:11.130] remote.SSH.enableDynamicForwarding = true
[21:23:11.130] remote.SSH.enableRemoteCommand = false
[21:23:11.131] remote.SSH.serverPickPortsFromRange = {}
[21:23:11.132] remote.SSH.serverInstallPath = {}
[21:23:11.132] remote.SSH.permitPtyAllocation = false
[21:23:11.132] remote.SSH.preferredLocalPortRange = undefined
[21:23:11.132] remote.SSH.useCurlAndWgetConfigurationFiles = false
[21:23:11.132] remote.SSH.experimental.chat = true
[21:23:11.132] remote.SSH.experimental.enhancedSessionLogs = true
[21:23:11.132] remote.SSH.httpProxy = {"*":""}
[21:23:11.132] remote.SSH.httpsProxy = {"*":""}
[21:23:11.135] VS Code version: 1.101.2
[21:23:11.135] Remote-SSH version: remote-ssh@0.120.0
[21:23:11.135] win32 x64
[21:23:11.139] SSH Resolver called for host: jkleemann@srv01:undefined
[21:23:11.139] Setting up SSH remote "srv01:undefined"
[21:23:11.148] Using commit id "2901c5ac6db8a986a5666c3af51ff804d05af0d4" and quality "stable" for server
[21:23:11.148] Extensions to install: 
[21:23:11.152] Install and start server if needed
[21:23:11.154] Checking ssh with "C:\Windows\system32\ssh.exe -V"
[21:23:11.156] Got error from ssh: spawn C:\Windows\system32\ssh.exe ENOENT
[21:23:11.156] Checking ssh with "C:\Windows\ssh.exe -V"
[21:23:11.157] Got error from ssh: spawn C:\Windows\ssh.exe ENOENT
[21:23:11.157] Checking ssh with "C:\Windows\System32\Wbem\ssh.exe -V"
[21:23:11.158] Got error from ssh: spawn C:\Windows\System32\Wbem\ssh.exe ENOENT
[21:23:11.158] Checking ssh with "C:\Windows\System32\WindowsPowerShell\v1.0\ssh.exe -V"
[21:23:11.158] Got error from ssh: spawn C:\Windows\System32\WindowsPowerShell\v1.0\ssh.exe ENOENT
[21:23:11.158] Checking ssh with "C:\Windows\System32\OpenSSH\ssh.exe -V"
[21:23:11.175] > OpenSSH_for_Windows_9.5p1, LibreSSL 3.8.2

[21:23:11.178] Using SSH config file "C:\Users\jkleemann\Linux\ssh_config.conf"
[21:23:11.178] Running script with connection command: "C:\Windows\System32\OpenSSH\ssh.exe" -T -D 61496 -F "C:\Users\jkleemann\Linux\ssh_config.conf" "jkleemann@srv01:undefined" sh
[21:23:11.180] Generated SSH command: 'type "C:\Users\JKLEEM~1\AppData\Local\Temp\vscode-linux-multi-line-command-srv01-undefined-831260769.sh" | "C:\Windows\System32\OpenSSH\ssh.exe" -T -D 61496 -F "C:\Users\jkleemann\Linux\ssh_config.conf" "jkleemann@srv01:undefined" sh'
[21:23:11.180] Using connect timeout of 17 seconds
[21:23:11.181] Terminal shell path: C:\WINDOWS\System32\cmd.exe
[21:23:11.389] > 
[21:23:11.389] Got some output, clearing connection timeout
[21:23:11.399] > ssh: Could not resolve hostname srv01:undefined.srv.phys.tu-darmstadt.de: Der angegebene Host ist unbekannt.
[21:23:11.419] > Ein Prozess hat versucht, zu einer nicht bestehenden Pipe zu schreiben.
[21:23:12.672] "install" terminal command done
[21:23:12.672] Install terminal quit with output: Ein Prozess hat versucht, zu einer nicht bestehenden Pipe zu schreiben.
[21:23:12.672] Received install output: Ein Prozess hat versucht, zu einer nicht bestehenden Pipe zu schreiben.
[21:23:12.673] WARN: $PLATFORM is undefined in installation script output.  Errors may be dropped.
[21:23:12.673] Failed to parse remote port from server output
[21:23:12.673] Resolver error: Error
    at y.Create (c:\Users\jkleemann\.vscode\extensions\ms-vscode-remote.remote-ssh-0.120.0\out\extension.js:2:744751)
    at t.handleInstallOutput (c:\Users\jkleemann\.vscode\extensions\ms-vscode-remote.remote-ssh-0.120.0\out\extension.js:2:742832)
    at t.tryInstall (c:\Users\jkleemann\.vscode\extensions\ms-vscode-remote.remote-ssh-0.120.0\out\extension.js:2:865534)
    at async c:\Users\jkleemann\.vscode\extensions\ms-vscode-remote.remote-ssh-0.120.0\out\extension.js:2:824246
    at async t.withShowDetailsEvent (c:\Users\jkleemann\.vscode\extensions\ms-vscode-remote.remote-ssh-0.120.0\out\extension.js:2:827501)
    at async A (c:\Users\jkleemann\.vscode\extensions\ms-vscode-remote.remote-ssh-0.120.0\out\extension.js:2:820760)
    at async t.resolve (c:\Users\jkleemann\.vscode\extensions\ms-vscode-remote.remote-ssh-0.120.0\out\extension.js:2:824898)
    at async c:\Users\jkleemann\.vscode\extensions\ms-vscode-remote.remote-ssh-0.120.0\out\extension.js:2:1113660
[21:23:12.676] ------




[21:23:12.677] No hints found in the recent session.
[21:23:13.185] Opening exec server for ssh-remote+7b22686f73744e616d65223a226c6461733035222c2275736572223a226a6b6c65656d616e6e227d
[21:23:13.194] Opening exec server for ssh-remote+7b22686f73744e616d65223a226c6461733035222c2275736572223a226a6b6c65656d616e6e227d
[21:23:13.200] Initizing new exec server for ssh-remote+7b22686f73744e616d65223a226c6461733035222c2275736572223a226a6b6c65656d616e6e227d
[21:23:13.200] Using commit id "2901c5ac6db8a986a5666c3af51ff804d05af0d4" and quality "stable" for server
[21:23:13.200] Extensions to install: 
[21:23:13.205] Install and start server if needed
[21:23:13.209] Using SSH config file "C:\Users\jkleemann\Linux\ssh_config.conf"
[21:23:13.209] Running script with connection command: "C:\Windows\System32\OpenSSH\ssh.exe" -T -D 61496 -F "C:\Users\jkleemann\Linux\ssh_config.conf" "jkleemann@srv01:undefined" sh
[21:23:13.210] Generated SSH command: 'type "C:\Users\JKLEEM~1\AppData\Local\Temp\vscode-linux-multi-line-command-srv01-undefined-220151712.sh" | "C:\Windows\System32\OpenSSH\ssh.exe" -T -D 61496 -F "C:\Users\jkleemann\Linux\ssh_config.conf" "jkleemann@srv01:undefined" sh'
[21:23:13.210] Using connect timeout of 17 seconds
[21:23:13.211] Terminal shell path: C:\WINDOWS\System32\cmd.exe
[21:23:13.403] > 
[21:23:13.403] Got some output, clearing connection timeout
[21:23:13.418] > ssh: Could not resolve hostname srv01:undefined.srv.phys.tu-darmstadt.de: Der angegebene Host ist unbekannt.
[21:23:13.435] > Ein Prozess hat versucht, zu einer nicht bestehenden Pipe zu schreiben.
[21:23:14.676] "install" terminal command done
[21:23:14.677] Install terminal quit with output: Ein Prozess hat versucht, zu einer nicht bestehenden Pipe zu schreiben.
[21:23:14.677] Received install output: Ein Prozess hat versucht, zu einer nicht bestehenden Pipe zu schreiben.
[21:23:14.677] WARN: $PLATFORM is undefined in installation script output.  Errors may be dropped.
[21:23:14.677] Failed to parse remote port from server output
[21:23:14.678] Exec server for ssh-remote+7b22686f73744e616d65223a226c6461733035222c2275736572223a226a6b6c65656d616e6e227d failed: Error
[21:23:14.678] Existing exec server for ssh-remote+7b22686f73744e616d65223a226c6461733035222c2275736572223a226a6b6c65656d616e6e227d errored (Error)
[21:23:14.678] Initizing new exec server for ssh-remote+7b22686f73744e616d65223a226c6461733035222c2275736572223a226a6b6c65656d616e6e227d
[21:23:14.679] Error opening exec server for ssh-remote+7b22686f73744e616d65223a226c6461733035222c2275736572223a226a6b6c65656d616e6e227d: Error
[21:23:14.679] No hints found in the recent session.
[21:23:14.679] Using commit id "2901c5ac6db8a986a5666c3af51ff804d05af0d4" and quality "stable" for server
[21:23:14.680] Extensions to install: 
[21:23:14.685] Install and start server if needed
[21:23:14.690] Using SSH config file "C:\Users\jkleemann\Linux\ssh_config.conf"
[21:23:14.690] Running script with connection command: "C:\Windows\System32\OpenSSH\ssh.exe" -T -D 61496 -F "C:\Users\jkleemann\Linux\ssh_config.conf" "jkleemann@srv01:undefined" sh
[21:23:14.691] Generated SSH command: 'type "C:\Users\JKLEEM~1\AppData\Local\Temp\vscode-linux-multi-line-command-srv01-undefined-681132756.sh" | "C:\Windows\System32\OpenSSH\ssh.exe" -T -D 61496 -F "C:\Users\jkleemann\Linux\ssh_config.conf" "jkleemann@srv01:undefined" sh'
[21:23:14.691] Using connect timeout of 17 seconds
[21:23:14.691] Terminal shell path: C:\WINDOWS\System32\cmd.exe
[21:23:15.060] > 
[21:23:15.060] Got some output, clearing connection timeout
[21:23:15.072] > ssh: Could not resolve hostname srv01:undefined.srv.phys.tu-darmstadt.de: Der angegebene Host ist unbekannt.
[21:23:15.092] > Ein Prozess hat versucht, zu einer nicht bestehenden Pipe zu schreiben.
[21:23:16.343] "install" terminal command done
[21:23:16.344] Install terminal quit with output: Ein Prozess hat versucht, zu einer nicht bestehenden Pipe zu schreiben.
[21:23:16.344] Received install output: Ein Prozess hat versucht, zu einer nicht bestehenden Pipe zu schreiben.
[21:23:16.344] WARN: $PLATFORM is undefined in installation script output.  Errors may be dropped.
[21:23:16.344] Failed to parse remote port from server output
[21:23:16.344] Exec server for ssh-remote+7b22686f73744e616d65223a226c6461733035222c2275736572223a226a6b6c65656d616e6e227d failed: Error
[21:23:16.345] Error opening exec server for ssh-remote+7b22686f73744e616d65223a226c6461733035222c2275736572223a226a6b6c65656d616e6e227d: Error
[21:23:16.345] No hints found in the recent session.

Expected Behavior

user@srv01 as ssh-remote target should work with an ssh config containing

Host srv*
    # Fully qualify the domain name for the internal network to prevent DNS issues
    HostName %h.all.domain.parts.com

since ssh user@srv01 on the terminal using the same ssh_config works fine.

Actual Behavior

Connection fails in VS Code, apparently since the host name gets messed up.

Steps To Reproduce
  1. Have an ssh_config containing
Host srv*
    # Fully qualify the domain name for the internal network to prevent DNS issues
    HostName %h.all.domain.parts.com
  1. Initiate a ssh-remote connection through "Remote-SSH: Connect to Host" of VS Code's command palette
  2. Use user@srv01 as target
  3. Apparently something confuses VS Code Remote so that it puts a :undefined in the the full hostname resulting in srv01:undefined.all.domain.parts.com, thus failing name resulution. Same happens if one uses user@srv01:22 as the target with undefined being swapped out for 22 in this case.
Anything else?

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the Remote-SSH: Connect to Host entry point and reproduce the issue with the shown ssh_config.conf Host srv* and HostName %h.all.domain.parts.com settings. Compare the generated SSH command with the working terminal command, focusing on the added :undefined or port suffix. Done means user@srv01 resolves as srv01.all.domain.parts.com without the malformed suffix.

Written by the indexing model from the issue text.

Assessment

Tech stack
vscode
Domain
devtools, networking
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.