Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Remote-SSH Bug]: Impossible to connect to same host twice #9889

Closed
3 tasks done
RomuAdq opened this issue May 16, 2024 · 2 comments
Closed
3 tasks done

[Remote-SSH Bug]: Impossible to connect to same host twice #9889

RomuAdq opened this issue May 16, 2024 · 2 comments
Assignees
Labels
info-needed Issue requires more information from poster ssh Issue in vscode-remote SSH

Comments

@RomuAdq
Copy link

RomuAdq commented May 16, 2024

Is there an existing issue for this bug?

  • I have searched the existing issues

Required Troubleshooting Steps

  • 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 response

Steps To Reproduce

  1. With VS Code 1.89.1, when I want to connect to a Windows Server 2022 with Open SSH Server
  2. The first time, the connection is OK but when I close my VS Code windows and I want to open a new one in order to reconnect to the same host
  3. Vs Code try to connect many times and fails
  4. I have the following error CodeError(CommandFailed { command: "bash", code: -1, output: "program not found" }): Error: CodeError(CommandFailed { command: "bash", code: -1, output: "program not found" })

Remote-SSH Log

Remote-SSH Log

Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

PS C:\Users\casdenpleskuser>
PS C:\Users\casdenpleskuser> $uuid="918398a5d762"
PS C:\Users\casdenpleskuser> "${uuid}: running"
918398a5d762: running
PS C:\Users\casdenpleskuser> "918398a5d762: pauseLog"
918398a5d762: pauseLog
PS C:\Users\casdenpleskuser> $ProgressPreference='SilentlyContinue'
PS C:\Users\casdenpleskuser> $r_='dc96b837cf6bb4af9cd736aa3af08cf8279f7685'
PS C:\Users\casdenpleskuser> $p=$env:PROCESSOR_ARCHITECTURE
PS C:\Users\casdenpleskuser> $arch=if (($p -eq 'AMD64') -or ($p -eq 'IA64')) { 'x64' } else { 'ia32' }
PS C:\Users\casdenpleskuser> 
PS C:\Users\casdenpleskuser> $s_=(Join-Path (Resolve-Path ~) '.vscode-server')
PS C:\Users\casdenpleskuser> $cliDataDir=(Join-Path "$s_" 'cli')
PS C:\Users\casdenpleskuser> $env:VSCODE_AGENT_FOLDER=$s_
PS C:\Users\casdenpleskuser> $log=New-TemporaryFile
PS C:\Users\casdenpleskuser> $c_="code"
PS C:\Users\casdenpleskuser> $d_="$c_.exe"
PS C:\Users\casdenpleskuser> $e_="$c_-$r_.exe"
PS C:\Users\casdenpleskuser> $f_="$s_\$e_"
PS C:\Users\casdenpleskuser> $t_='stable'
PS C:\Users\casdenpleskuser> $k_=$True
PS C:\Users\casdenpleskuser> $l_=$False
PS C:\Users\casdenpleskuser> $global:v_ = $False
PS C:\Users\casdenpleskuser> $global:w_ = ''
PS C:\Users\casdenpleskuser> $global:n_ = ''
PS C:\Users\casdenpleskuser> $global:o_ = ''
PS C:\Users\casdenpleskuser> $global:p_ = ''
PS C:\Users\casdenpleskuser> $global:q_ = ''
PS C:\Users\casdenpleskuser> function ak_ {
>> "listeningOn==$port=="
>> "osReleaseId==windows=="
>> "osVersion==$ai_=="
>> "arch==$arch=="
>> "platform==windows=="
>> "unpackResult==$w_=="
>> "didLocalDownload==$v_=="
>> "downloadTime==$n_=="
>> "installTime==$o_=="
>> "extInstallTime==$p_=="
>> "serverStartTime==$q_=="
>> "execServerToken==4083c86f-1c10-4db8-96bd-00b27b73f5e1=="
>> }
>>
PS C:\Users\casdenpleskuser> function m_ {
>> return [system.diagnostics.stopwatch]::StartNew();
>> }
>>
PS C:\Users\casdenpleskuser> function q($code) {
>> "${uuid}: start"
>> "exitCode==$code=="
>> ak_
>> "${uuid}: end"
>> }
>>
PS C:\Users\casdenpleskuser> function a_ {
>> $x_=$PID
>> while ($True) {
>> $y_=(gcim win32_process | ? processid -eq $x_).parentprocessid
>> if (!$y_) {
>> "no sshd parent proc"
>> exit 0
>> }
>>
>> if ((gps -Id $y_).Name -eq 'sshd') {
>> return $y_
>> }
>>
>> $x_=$y_
>> }
>>
>> }
>>
PS C:\Users\casdenpleskuser> function b_ {
>> if ($launchedCli1Pid) {
>> if (!(gps -Id $z_)) {
>> "server died, exit"
>> exit 0
>> }
>>
>> } else {
>> if (!(gps -Id $sshdPID)) {
>> "sshd parent died, exit"
>> exit 0
>> }
>>
>> }
>>
>> }
>>
PS C:\Users\casdenpleskuser> function GetArtifactName {
>> $aa_=if ($arch -eq 'x64') { "-$arch" } else { "" }
>>
>> "cli-win32$aa_"
>> }
>>
PS C:\Users\casdenpleskuser> function g_ {
>> $s=m_
>> "Downloading cli $arch"
>> "${uuid}%%1%%"
>> $an=GetArtifactName
>> $splat=@{
>> Uri="https://update.code.visualstudio.com/commit:$r_/$an/$t_"
>> TimeoutSec=20
>> OutFile="vscode-cli-$r_.zip"
>> UseBasicParsing=$True
>> }
>>
>> [Net.ServicePointManager]::SecurityProtocol = 'Tls12'
>> irm @splat
>> $s.Stop()
>> $global:n_ = $s.ElapsedMilliseconds
>> }
>>
PS C:\Users\casdenpleskuser> function h_ {
>> $global:w_='success'
>> $s=m_
>> try {
>> $ac_=[System.IO.Path]::GetRandomFileName()
>> $ad_="$env:TEMP\$ac_"
>> "Expanding cli into $ad_"
>> "${uuid}%%2%%"
>> Expand-Archive "vscode-cli-$r_.zip" -DestinationPath "$ad_"
>> cp "$ad_\$d_" -Destination $f_
>> del -Recurse $ad_
>> del "vscode-cli-$r_.zip"
>> $s.Stop()
>> $global:o_ = $s.ElapsedMilliseconds
>> } catch {
>> $global:w_='error'
>> "Failed to unzip cli. - $($_.ToString())"
>> j_ 37
>> h_
>> }
>>
>> if(!(Test-Path "$f_")) {
>> $global:w_='missingFiles'
>> "Downloaded server is incomplete."
>> j_ 37
>> h_
>> }
>>
>> }
>>
PS C:\Users\casdenpleskuser> function aj_ {
>> $s=m_
>> if(Test-Path $log) {
>> del $log
>> }
>>
>> $escapedCliFile=$f_ -replace ' ', '` '
>> $args="command-shell --cli-data-dir '$cliDataDir' --parent-process-id $sshdPID --on-port --require-token 4083c86f-1c10-4db8-96bd-00b27b73f5e1 *> '$log'"
>> $splat=@{
>> FilePath = "powershell.exe"
>> WindowStyle = "hidden"
>> ArgumentList = @(
>> "-ExecutionPolicy", "Unrestricted", "-NoLogo", "-NoProfile", "-NonInteractive", "-c", "$escapedCliFile $args"
>> )
>> PassThru = $True
>> }
>>
>> "Starting cli: & '$f_' $args"
>> $global:z_ = (start @splat).ID
>> $s.Stop()
>> $global:q_ = $s.ElapsedMilliseconds
>> }
>>
PS C:\Users\casdenpleskuser> function i_ {
>> $global:v_=$True
>> "Trigger local server download"
>> $an=GetArtifactName
>> "${uuid}:trigger_server_download"
>> "artifact==$an=="
>> "destFolder==$s_=="
>> "destFolder2==/vscode-cli-$r_.zip=="
>> "${uuid}:trigger_server_download_end"
>> "Waiting for client to transfer server archive..."
>> "Waiting for $s_\vscode-cli-$r_.zip.done and vscode-cli-$r_.zip to exist"
>> while($True) {
>> if(Test-Path "$s_\vscode-cli-$r_.zip.done") {
>> if(!(Test-Path "$s_\vscode-cli-$r_.zip")) {
>> "Transfer failed"
>> q 31
>> }
>>
>> "Transfer complete"
>> del $s_\vscode-cli-$r_.zip.done
>> break
>> } else {
>> Start-Sleep -Seconds 3
>> b_
>> }
>>
>> }
>>
>> }
>>
PS C:\Users\casdenpleskuser> function j_($code) {
>> if ($v_) {
>> "Already attempted local download, failing"
>> q $code
>> } elseif($k_) {
>> i_
>> } else {
>> q $code
>> }
>>
>> }
>>
PS C:\Users\casdenpleskuser> function printResult() {
>> "${uuid}: start"
>> "SSH_AUTH_SOCK==$env:SSH_AUTH_SOCK=="
>> ak_
>> "${uuid}: end"
>> }
>>
PS C:\Users\casdenpleskuser> function main() {
>> $global:sshdPID = a_
>> if(!(Test-Path $s_)) {
>> $m="Could not create CLI directory"
>> try {
>> $null=ni -it d $s_ -f -ea si
>> } catch {
>> "$m. - $($_.ToString())"
>> return
>> }
>>
>> if(!(Test-Path $s_)) {
>> "$m"
>> return
>> }
>>
>> }
>>
>> cd $s_
>> try {
>> "Looking for existing CLI in $s_"
>> if(Test-Path "$f_") {
>> "Found installed CLI"
>> } else {
>> if ($l_) {
>> i_
>> } else {
>> try { g_ } catch {
>> "Download failed. - $($_.ToString())"
>> j_ 25
>> }
>>
>> }
>>
>> h_
>> }
>>
>> aj_
>> $ag_=@{
>> Path = $log
>> Pattern = "Listening on 127.0.0.1:(.+)"
>> }
>>
>> $af_=(Get-Date).AddSeconds(4)
>> $al_="Server did not start successfully. Full server log at $log >>>"
>> while ((Get-Date) -lt $af_) {
>> if(Test-Path $log) {
>> $ah_=(sls @ag_).Matches.Groups
>> if($ah_) {
>> $global:port = $ah_[1].Value
>> break
>> }
>>
>> }
>>
>> sleep -Milliseconds 30
>> }
>>
>> if (!$port) {
>> $al_
>> cat $log
>> "<<< End of server log"
>> q 32
>> }
>>
>> } catch {
>> "Server failed to start. - $($_.ToString())"
>> "$($_.ScriptStackTrace)"
>> }
>>
>> try {
>> $global:ai_ = (gcim Win32_OperatingSystem).Version
>> } catch {
>> "Failed to find Windows version - $($_.ToString())"
>> $global:ai_ = "unknown"
>> }
>>
>> printResult
>> "$pid, watching $sshdPID"
>> while ($True) {
>> b_
>> sleep 30
>> }
>>
>> }
>>
PS C:\Users\casdenpleskuser> "918398a5d762: resumeLog"
918398a5d762: resumeLog
PS C:\Users\casdenpleskuser> main
Looking for existing CLI in C:\Users\casdenpleskuser\.vscode-server
Found installed CLI
Starting cli: & 'C:\Users\casdenpleskuser\.vscode-server\code-dc96b837cf6bb4af9cd736aa3af08cf8279f7685.exe' command-shell --cli-data-dir 'C:\Users\casdenpleskuser\.vscode-server\cli' --parent-process-id 8712 --on-port --require-token 4083c86f-1c10-4db8-96bd-00b27b73f5e1 *> 'C:\Users\casdenpleskuser\AppData\Local\Temp\tmpC023.tmp'
918398a5d762: start
SSH_AUTH_SOCK====
listeningOn==54264==
osReleaseId==windows==
osVersion==10.0.17763==
arch==x64==
platform==windows==
unpackResult====
didLocalDownload==False==
downloadTime====
installTime====
extInstallTime====
serverStartTime==33==
execServerToken==4083c86f-1c10-4db8-96bd-00b27b73f5e1==
918398a5d762: end
14884, watching 8712

Anything else?

No response

@RomuAdq RomuAdq added the ssh Issue in vscode-remote SSH label May 16, 2024
@roblourens roblourens assigned connor4312 and unassigned roblourens May 17, 2024
@connor4312
Copy link
Member

I think you may have selected the remote platform for that host as Linux. Please check your remote.SSH.remotePlatform user setting and verify whether the host is correct in there. Thanks!

@connor4312 connor4312 added the info-needed Issue requires more information from poster label May 20, 2024
@VSCodeTriageBot
Copy link
Collaborator

This issue has been closed automatically because it needs more information and has not had recent activity. See also our issue reporting guidelines.

Happy Coding!

@VSCodeTriageBot VSCodeTriageBot closed this as not planned Won't fix, can't repro, duplicate, stale May 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
info-needed Issue requires more information from poster ssh Issue in vscode-remote SSH
Projects
None yet
Development

No branches or pull requests

4 participants