Repository: vscode
Issue: [Remote-SSH Bug]: Error: AttachConsole failed, could not find pty on pty host
Labels: windows,under-discussion,ssh

### Is there an existing issue for this bug?

- [X] I have searched the existing issues

### Required Troubleshooting Steps

- [X] I have followed these troubleshooting steps
- [ ] I have tried both values of the `remote.SSH.useLocalServer` setting

### Connect Locally

It connects successfully

### ->

_No response_

### Expected Behavior

No error spew in the "Remote - SSH" log.

### Steps To Reproduce

On connecting to a remote Windows host, I am now seeing console spew indicating that `getConsoleProcessList(shellPid)` fails with "Error: AttachConsole failed" and some "Could not find pty on pty host" errors.

### Remote-SSH Log

<details>
<summary>Remote-SSH Log</summary>
<p>

```
[16:05:38.340] Log Level: 2
[16:05:38.384] VS Code version: 1.82.0-insider
[16:05:38.384] Remote-SSH version: remote-ssh@0.105.1
[16:05:38.385] win32 x64
[16:05:38.388] SSH Resolver called for "ssh-remote+wave_analysis", attempt 1
[16:05:38.389] "remote.SSH.useLocalServer": false
[16:05:38.389] "remote.SSH.showLoginTerminal": false
[16:05:38.390] "remote.SSH.remotePlatform": {"wave_analysis":"windows","one_click":"windows","publics":"windows","prime":"windows","azure_devops":"windows","wave_analysis_linux_test":"linux"}
[16:05:38.390] "remote.SSH.path": undefined
[16:05:38.390] "remote.SSH.configFile": undefined
[16:05:38.390] "remote.SSH.useFlock": true
[16:05:38.390] "remote.SSH.lockfilesInTmp": false
[16:05:38.391] "remote.SSH.localServerDownload": auto
[16:05:38.391] "remote.SSH.remoteServerListenOnSocket": false
[16:05:38.391] "remote.SSH.showLoginTerminal": false
[16:05:38.392] "remote.SSH.defaultExtensions": []
[16:05:38.392] "remote.SSH.loglevel": 2
[16:05:38.392] "remote.SSH.enableDynamicForwarding": true
[16:05:38.392] "remote.SSH.enableRemoteCommand": false
[16:05:38.393] "remote.SSH.serverPickPortsFromRange": {}
[16:05:38.393] "remote.SSH.serverInstallPath": {}
[16:05:38.407] SSH Resolver called for host: wave_analysis
[16:05:38.407] Setting up SSH remote "wave_analysis"
[16:05:38.419] Using commit id "501baeb5e07b5a404f862d922bacb93771d91331" and quality "insider" for server
[16:05:38.427] Install and start server if needed
[16:05:38.453] Checking ssh with "C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\wbin\ssh.exe -V"
[16:05:38.465] Got error from ssh: spawn C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\wbin\ssh.exe ENOENT
[16:05:38.466] Checking ssh with "C:\Windows\system32\ssh.exe -V"
[16:05:38.471] Got error from ssh: spawn C:\Windows\system32\ssh.exe ENOENT
[16:05:38.472] Checking ssh with "C:\Windows\ssh.exe -V"
[16:05:38.477] Got error from ssh: spawn C:\Windows\ssh.exe ENOENT
[16:05:38.478] Checking ssh with "C:\Windows\System32\Wbem\ssh.exe -V"
[16:05:38.481] Got error from ssh: spawn C:\Windows\System32\Wbem\ssh.exe ENOENT
[16:05:38.482] Checking ssh with "C:\Windows\System32\WindowsPowerShell\v1.0\ssh.exe -V"
[16:05:38.486] Got error from ssh: spawn C:\Windows\System32\WindowsPowerShell\v1.0\ssh.exe ENOENT
[16:05:38.487] Checking ssh with "C:\Windows\System32\OpenSSH\ssh.exe -V"
[16:05:38.766] > OpenSSH_for_Windows_8.6p1, 
[16:05:38.767] > LibreSSL 3.4.3

[16:05:38.777] Remote command length: 4809/8192 characters
[16:05:38.777] Running script with connection command: "C:\Windows\System32\OpenSSH\ssh.exe" -T -D 56762 "wave_analysis" powershell
[16:05:38.784] Terminal shell path: C:\Windows\System32\cmd.exe
[16:05:45.669] > Windows PowerShell
> Copyright (C) Microsoft Corporation. All rights reserved.Install the latest PowerShell for new features and improvements! https://aka.ms/PSWindows]0;C:\Windows\System32\cmd.exe
[16:05:45.670] Got some output, clearing connection timeout
[16:05:45.712] > PS C:\Users\winstonliu> 
> PS C:\Users\winstonliu> $uuid="b3a211a33b5b"
> PS C:\Users\winstonliu> "${uuid}: running"
> b3a211a33b5b: running
> PS C:\Users\winstonliu> "b3a211a33b5b: pauseLog"
> b3a211a33b5b: pauseLog
[16:05:46.654] > 
[16:05:47.160] > Looking for existing CLI in C:\Users\winstonliu\.vscode-server-insiders
[16:05:47.202] > 
> Found installed CLI
> Starting cli: & 'C:\Users\winstonliu\.vscode-server-insiders\code-insiders-501ba
> aeb5e07b5a404f862d922bacb93771d91331.exe' command-shell --cli-data-dir 'C:\Users\
> \winstonliu\.vscode-server-insiders\cli' --on-port --require-token 3f59eb4538a6 *
> *> 'C:\Users\winstonliu\AppData\Local\Temp\tmp3949.tmp'
[16:05:47.238] > 
[16:05:47.683] > b3a211a33b5b: start
> SSH_AUTH_SOCK====
> listeningOn==60783==
> osReleaseId==windows==
> osVersion==10.0.22000==
> arch==x64==
> platform==windows==
> unpackResult====
> didLocalDownload==False==
> downloadTime====
> installTime====
> extInstallTime====
> serverStartTime==63==
> b3a211a33b5b: end
[16:05:47.685] Received install output: 
SSH_AUTH_SOCK====
listeningOn==60783==
osReleaseId==windows==
osVersion==10.0.22000==
arch==x64==
platform==windows==
unpackResult====
didLocalDownload==False==
downloadTime====
installTime====
extInstallTime====
serverStartTime==63==

[16:05:47.687] Remote server is listening on port 60783
[16:05:47.687] Parsed server configuration: {"serverConfiguration":{"remoteListeningOn":{"port":60783},"osReleaseId":"windows","arch":"x64","sshAuthSock":"","platform":"windows"},"serverStartTime":63,"installUnpackCode":""}
[16:05:47.704] Starting forwarding server. local port 56774 -> socksPort 56762 -> remotePort 60783
[16:05:47.706] Forwarding server listening on port 56774
[16:05:47.707] Waiting for ssh tunnel to be ready
[16:05:47.711] [Forwarding server port 56774] Got connection 0
[16:05:47.715] Tunneled port 60783 to local port 56774
[16:05:47.716] Resolved "ssh-remote+wave_analysis" to "port 56774"
[16:05:47.732] Resolving exec server at port 56774
[16:05:47.821] > 
> 9180, watching 5500
[16:05:47.841] [Forwarding server port 56774] Got connection 1
[16:05:48.222] Exec server connection established
[16:05:48.254] ------




[16:05:48.367] [server] Checking C:\Users\winstonliu\.vscode-server-insiders\cli\servers\Insiders-501baeb5e07b5a404f862d922bacb93771d91331\log.txt and C:\Users\winstonliu\.vscode-server-insiders\cli\servers\Insiders-501baeb5e07b5a404f862d922bacb93771d91331\pid.txt for a running server...
[16:05:48.441] [server] Installing and setting up Visual Studio Code Server...
[16:05:48.442] [server] Server setup complete
[16:05:48.443] [server] Starting server...
[16:05:48.443] [server] Starting server with command... Command { std: "cmd" "/Q" "/C" "C:\\Users\\winstonliu\\.vscode-server-insiders\\cli\\servers\\Insiders-501baeb5e07b5a404f862d922bacb93771d91331\\server\\bin\\code-server-insiders.cmd" "--connection-token=remotessh" "--accept-server-license-terms" "--start-server" "--enable-remote-auto-shutdown" "--socket-path=\\\\.\\pipe\\code-insiders-dbef124c-c97f-4916-bb58-6b8505dc4223", kill_on_drop: false }
[16:05:49.250] [server] *
[16:05:49.252] [server] * Visual Studio Code Server
[16:05:49.252] [server] *
[16:05:49.252] [server] * By using the software, you agree to
[16:05:49.253] [server] * the Visual Studio Code Server License Terms (https://aka.ms/vscode-server-license) and
[16:05:49.253] [server] * the Microsoft Privacy Statement (https://privacy.microsoft.com/en-US/privacystatement).
[16:05:49.254] [server] *
[16:05:49.254] [server] Server bound to \\.\pipe\code-insiders-dbef124c-c97f-4916-bb58-6b8505dc4223
[16:05:49.254] [server] Extension host agent listening on \\.\pipe\code-insiders-dbef124c-c97f-4916-bb58-6b8505dc4223
[16:05:49.255] [server] parsed location: "\\\\.\\pipe\\code-insiders-dbef124c-c97f-4916-bb58-6b8505dc4223"
[16:05:49.255] [server] 
[16:05:49.271] [server] Server started
[16:05:49.854] [server] [19:05:49] 
[16:05:49.918] [server] 
[16:05:49.919] [server] 
[16:05:49.919] [server] 
[16:05:49.985] [server] [19:05:49] Extension host agent started.
[16:05:50.522] [server] [19:05:50] [<unknown>][74557edb][ManagementConnection] New connection established.
[16:05:50.525] [server] [19:05:50] [<unknown>][a38f18a8][ExtensionHostConnection] New connection established.
[16:05:50.551] [server] [19:05:50] [<unknown>][a38f18a8][ExtensionHostConnection] <7560> Launched Extension Host Process.
[16:05:52.866] [server] [19:05:52] WSL is not installed, so could not detect WSL profiles
[16:05:58.500] [server] c:\Users\winstonliu\.vscode-server-insiders\cli\servers\Insiders-501baeb5e07b5a404f862d922bacb93771d91331\server\node_modules\node-pty\lib\conpty_console_list_agent.js:17
[16:05:58.503] [server] var consoleProcessList = getConsoleProcessList(shellPid);
[16:05:58.504] [server]                          ^
[16:05:58.506] [server] 
[16:05:58.506] [server] Error: AttachConsole failed
[16:05:58.507] [server] Node.js v18.15.0
[16:05:58.508] [server] c:\Users\winstonliu\.vscode-server-insiders\cli\servers\Insiders-501baeb5e07b5a404f862d922bacb93771d91331\server\node_modules\node-pty\lib\conpty_console_list_agent.js:17
[16:05:58.508] [server] var consoleProcessList = getConsoleProcessList(shellPid);
[16:05:58.509] [server]                          ^
[16:05:58.509] [server] 
[16:05:58.509] [server]     at Object.<anonymous> (c:\Users\winstonliu\.vscode-server-insiders\cli\servers\Insiders-501baeb5e07b5a404f862d922bacb93771d91331\server\node_modules\node-pty\lib\conpty_console_list_agent.js:17:26)
[16:05:58.510] [server] 
[16:05:58.510] [server] Node.js v18.15.0
[16:05:58.511] [server] c:\Users\winstonliu\.vscode-server-insiders\cli\servers\Insiders-501baeb5e07b5a404f862d922bacb93771d91331\server\node_modules\node-pty\lib\conpty_console_list_agent.js:17
[16:05:58.511] [server] var consoleProcessList = getConsoleProcessList(shellPid);
[16:05:58.512] [server]                          ^
[16:05:58.513] [server] 
[16:05:58.515] [server] Error: AttachConsole failed
[16:05:58.516] [server] 
[16:05:58.517] [server] c:\Users\winstonliu\.vscode-server-insiders\cli\servers\Insiders-501baeb5e07b5a404f862d922bacb93771d91331\server\node_modules\node-pty\lib\conpty_console_list_agent.js:17
[16:05:58.517] [server] var consoleProcessList = getConsoleProcessList(shellPid);
[16:05:58.517] [server]                          ^
[16:05:58.518] [server] 
[16:05:58.519] [server] Error: AttachConsole failed
[16:05:58.520] [server]     at Module._extensions..js (node:internal/modules/cjs/loader:1308:10)
[16:05:58.520] [server]     at Module.load (node:internal/modules/cjs/loader:1117:32)
[16:05:58.521] [server]     at Module._load (node:internal/modules/cjs/loader:958:12)
[16:05:58.522] [server]     at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
[16:05:58.523] [server]     at node:internal/main/run_main_module:23:47
[16:05:58.524] [server] 
[16:05:58.524] [server] Node.js v18.15.0
[16:05:59.872] [server] rejected promise not handled within 1 second: CodeExpectedError: Could not find pty on pty host
[16:05:59.876] [server] stack trace: CodeExpectedError: Could not find pty on pty host
[16:05:59.883] [server]     at m.P (c:\Users\winstonliu\.vscode-server-insiders\cli\servers\Insiders-501baeb5e07b5a404f862d922bacb93771d91331\server\out\vs\platform\terminal\node\ptyHostMain.js:28:7536)
[16:05:59.884] [server]     at m.updateTitle (c:\Users\winstonliu\.vscode-server-insiders\cli\servers\Insiders-501baeb5e07b5a404f862d922bacb93771d91331\server\out\vs\platform\terminal\node\ptyHostMain.js:28:2697)
[16:05:59.885] [server]     at W.<computed> (c:\Users\winstonliu\.vscode-server-insiders\cli\servers\Insiders-501baeb5e07b5a404f862d922bacb93771d91331\server\out\vs\platform\terminal\node\ptyHostMain.js:27:22755)
[16:05:59.887] [server]     at c.q (c:\Users\winstonliu\.vscode-server-insiders\cli\servers\Insiders-501baeb5e07b5a404f862d922bacb93771d91331\server\out\vs\platform\terminal\node\ptyHostMain.js:15:4661)
[16:05:59.888] [server] [19:05:59] Error [CodeExpectedError]: Could not find pty on pty host
[16:05:59.892] [server]     at m.P (c:\Users\winstonliu\.vscode-server-insiders\cli\servers\Insiders-501baeb5e07b5a404f862d922bacb93771d91331\server\out\vs\platform\terminal\node\ptyHostMain.js:28:7536)
[16:05:59.893] [server]     at m.updateTitle (c:\Users\winstonliu\.vscode-server-insiders\cli\servers\Insiders-501baeb5e07b5a404f862d922bacb93771d91331\server\out\vs\platform\terminal\node\ptyHostMain.js:28:2697)
[16:05:59.894] [server]     at W.<computed> (c:\Users\winstonliu\.vscode-server-insiders\cli\servers\Insiders-501baeb5e07b5a404f862d922bacb93771d91331\server\out\vs\platform\terminal\node\ptyHostMain.js:27:22755)
[16:05:59.896] [server] rejected promise not handled within 1 second: CodeExpectedError: Could not find pty on pty host
[16:05:59.899] [server] stack trace: CodeExpectedError: Could not find pty on pty host
[16:05:59.901] [server]     at m.P (c:\Users\winstonliu\.vscode-server-insiders\cli\servers\Insiders-501baeb5e07b5a404f862d922bacb93771d91331\server\out\vs\platform\terminal\node\ptyHostMain.js:28:7536)
[16:05:59.902] [server]     at m.updateIcon (c:\Users\winstonliu\.vscode-server-insiders\cli\servers\Insiders-501baeb5e07b5a404f862d922bacb93771d91331\server\out\vs\platform\terminal\node\ptyHostMain.js:28:2748)
[16:05:59.902] [server]     at W.<computed> (c:\Users\winstonliu\.vscode-server-insiders\cli\servers\Insiders-501baeb5e07b5a404f862d922bacb93771d91331\server\out\vs\platform\terminal\node\ptyHostMain.js:27:22755)
[16:05:59.903] [server]     at Object.call (c:\Users\winstonliu\.vscode-server-insiders\cli\servers\Insiders-501baeb5e07b5a404f862d922bacb93771d91331\server\out\vs\platform\terminal\node\ptyHostMain.js:17:4866)
[16:05:59.903] [server]     at c.s (c:\Users\winstonliu\.vscode-server-insiders\cli\servers\Insiders-501baeb5e07b5a404f862d922bacb93771d91331\server\out\vs\platform\terminal\node\ptyHostMain.js:15:5150)
[16:05:59.904] [server]     at c.q (c:\Users\winstonliu\.vscode-server-insiders\cli\servers\Insiders-501baeb5e07b5a404f862d922bacb93771d91331\server\out\vs\platform\terminal\node\ptyHostMain.js:15:4661)
[16:05:59.904] [server]     at n.value (c:\Users\winstonliu\.vscode-server-insiders\cli\servers\Insiders-501baeb5e07b5a404f862d922bacb93771d91331\server\out\vs\platform\terminal\node\ptyHostMain.js:15:4066)
[16:05:59.905] [server]     at w (c:\Users\winstonliu\.vscode-server-insiders\cli\servers\Insiders-501baeb5e07b5a404f862d922bacb93771d91331\server\out\vs\platform\terminal\node\ptyHostMain.js:10:1902)
[16:05:59.905] [server]     at w.fire (c:\Users\winstonliu\.vscode-server-insiders\cli\servers\Insiders-501baeb5e07b5a404f862d922bacb93771d91331\server\out\vs\platform\terminal\node\ptyHostMain.js:10:2119)
[16:05:59.908] [server]     at process.q (c:\Users\winstonliu\.vscode-server-insiders\cli\servers\Insiders-501baeb5e07b5a404f862d922bacb93771d91331\server\out\vs\platform\terminal\node\ptyHostMain.js:8:27274)
[16:05:59.909] [server]     at process.emit (node:events:513:28)
[16:05:59.910] [server]     at emit (node:internal/child_process:937:14)
[16:05:59.911] [server]     at process.processTicksAndRejections (node:internal/process/task_queues:83:21)
[16:05:59.912] [server] [19:05:59] Error [CodeExpectedError]: Could not find pty on pty host
[16:05:59.913] [server]     at m.P (c:\Users\winstonliu\.vscode-server-insiders\cli\servers\Insiders-501baeb5e07b5a404f862d922bacb93771d91331\server\out\vs\platform\terminal\node\ptyHostMain.js:28:7536)
[16:05:59.925] [server]     at m.updateIcon (c:\Users\winstonliu\.vscode-server-insiders\cli\servers\Insiders-501baeb5e07b5a404f862d922bacb93771d91331\server\out\vs\platform\terminal\node\ptyHostMain.js:28:2748)
[16:05:59.926] [server]     at W.<computed> (c:\Users\winstonliu\.vscode-server-insiders\cli\servers\Insiders-501baeb5e07b5a404f862d922bacb93771d91331\server\out\vs\platform\terminal\node\ptyHostMain.js:27:22755)
[16:05:59.926] [server]     at Object.call (c:\Users\winstonliu\.vscode-server-insiders\cli\servers\Insiders-501baeb5e07b5a404f862d922bacb93771d91331\server\out\vs\platform\terminal\node\ptyHostMain.js:17:4866)
[16:10:49.939] [server] New EH opened, aborting shutdown
[16:10:49.978] [server] [19:10:50] New EH opened, aborting shutdown

```

</p>
</details>


### Anything else?

_No response_