getcursor / cursor

The AI Code Editor
https://cursor.com
22.61k stars 1.45k forks source link

SSH to Windows remote no longer working #858

Open jorge-menjivar opened 1 year ago

jorge-menjivar commented 1 year ago

I am trying to connect to a remote machine through ssh. It had been working fine until I updated cursor to 0.9.3, from 8.6 or 9.0 (not sure).

The host is Fedora 38, the remote is Windows 11. I removed the .cursor-server dir on the remote, but it did not help.

This seems like a case of the download URL being corrupted or the blob not existing.

# Check if server script is already installed
if(!(Test-Path $SERVER_SCRIPT)) {
    del vscode-server.tar.gz

    $REQUEST_ARGUMENTS = @{
        Uri="https://cursor.blob.core.windows.net/remote-releases/0.9.3-e83fb25fe9144aa8b230e6f9ee2056e20fb24c70/vscode-reh-win32-x64.tar.gz"
        TimeoutSec=20
        OutFile="vscode-server.tar.gz"
        UseBasicParsing=$True
    }

    [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12

    Invoke-RestMethod @REQUEST_ARGUMENTS

    if(Test-Path "vscode-server.tar.gz") {
        tar -xf vscode-server.tar.gz --strip-components 1

        del vscode-server.tar.gz
    }

    if(!(Test-Path $SERVER_SCRIPT)) {
        "Error while installing the server binary"
        exit 1
    }
}
else {
    "Server script already installed in $SERVER_SCRIPT"
}

# Try to find if server is already running
if(Get-Process node -ErrorAction SilentlyContinue | Where-Object Path -Like "$SERVER_DIR\*") {
    echo "Server script is already running $SERVER_SCRIPT"
}
else {
    if(Test-Path $SERVER_LOGFILE) {
        del $SERVER_LOGFILE
    }
    if(Test-Path $SERVER_PIDFILE) {
        del $SERVER_PIDFILE
    }
    if(Test-Path $SERVER_TOKENFILE) {
        del $SERVER_TOKENFILE
    }

    $SERVER_CONNECTION_TOKEN="1a4a4181-4b9d-4a5f-8314-0f3c63ec18e1"
    [System.IO.File]::WriteAllLines($SERVER_TOKENFILE, $SERVER_CONNECTION_TOKEN)

    $SCRIPT_ARGUMENTS="--start-server --host=127.0.0.1 $SERVER_LISTEN_FLAG $SERVER_INITIAL_EXTENSIONS --connection-token-file $SERVER_TOKENFILE --telemetry-level off --enable-remote-auto-shutdown --accept-server-license-terms *> '$SERVER_LOGFILE'"

    $START_ARGUMENTS = @{
        FilePath = "powershell.exe"
        WindowStyle = "hidden"
        ArgumentList = @(
            "-ExecutionPolicy", "Unrestricted", "-NoLogo", "-NoProfile", "-NonInteractive", "-c", "$SERVER_SCRIPT $SCRIPT_ARGUMENTS"
        )
        PassThru = $True
    }

    $SERVER_ID = (start @START_ARGUMENTS).ID

    if($SERVER_ID) {
        [System.IO.File]::WriteAllLines($SERVER_PIDFILE, $SERVER_ID)
    }
}

if(Test-Path $SERVER_TOKENFILE) {
    $SERVER_CONNECTION_TOKEN="$(cat $SERVER_TOKENFILE)"
}
else {
    "Error server token file not found $SERVER_TOKENFILE"
    printInstallResults 1
    exit 0
}

sleep -Milliseconds 500

$SELECT_ARGUMENTS = @{
    Path = $SERVER_LOGFILE
    Pattern = "Extension host agent listening on (\d+)"
}

for($I = 1; $I -le 5; $I++) {
    if(Test-Path $SERVER_LOGFILE) {
        $GROUPS = (Select-String @SELECT_ARGUMENTS).Matches.Groups

        if($GROUPS) {
            $LISTENING_ON = $GROUPS[1].Value
            break
        }
    }

    sleep -Milliseconds 500
}

if(!(Test-Path $SERVER_LOGFILE)) {
    "Error server log file not found $SERVER_LOGFILE"
    printInstallResults 1
    exit 0
}

# Finish server setup
printInstallResults 0

if($SERVER_ID) {
    while($True) {
        if(!(gps -Id $SERVER_ID)) {
            "server died, exit"
            exit 0
        }

        sleep 30
    }
}

[Trace  - 18:16:12.977] Command length (8191 max):
4886
[Trace  - 18:16:13.905] Server install command stderr:
del : Cannot find path 
'C:\Users\jorge\.cursor-server\bin\0.9.3-e83fb25fe9144aa8b230e6f9ee2056e20fb24c70\vscode-server.tar.gz' because it 
does not exist.
At C:\Users\jorge\.cursor-server\install\e83fb25fe9144aa8b230e6f9ee2056e20fb24c70.ps1:57 char:1
+ del vscode-server.tar.gz
+ ~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (C:\Users\jorge\...e-server.tar.gz:String) [Remove-Item], ItemNotFoundEx 
   ception
    + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.RemoveItemCommand

Invoke-RestMethod : BlobNotFoundThe specified blob does not exist.
RequestId:87227b69-401e-005f-2ac9-ddd798000000
Time:2023-09-02T18:16:13.8440360Z
At C:\Users\jorge\.cursor-server\install\e83fb25fe9144aa8b230e6f9ee2056e20fb24c70.ps1:65 char:1
+ Invoke-RestMethod @REQUEST_ARGUMENTS
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebExc 
   eption
    + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand

[Trace  - 18:16:13.905] Server install command stdout:

    Directory: C:\Users\jorge\.cursor-server

Mode                 LastWriteTime         Length Name                                                                 
----                 -------------         ------ ----                                                                 
d-----          9/2/2023  11:16 AM                install                                                              

    Directory: C:\Users\jorge\.cursor-server\bin

Mode                 LastWriteTime         Length Name                                                                 
----                 -------------         ------ ----                                                                 
d-----          9/2/2023  11:16 AM                0.9.3-e83fb25fe9144aa8b230e6f9ee2056e20fb24c70                       
Error while installing the server binary

[Error  - 18:16:13.905] Error resolving authority
Error: Failed parsing install script output
    at t.installCodeServer (/tmp/.mount_cursorpxNXdW/resources/app/extensions/open-remote-ssh/dist/main.js:1:763139)
    at process.processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async /tmp/.mount_cursorpxNXdW/resources/app/extensions/open-remote-ssh/dist/main.js:1:438101
keselasela commented 5 months ago

I have the same issue.

jorge-menjivar commented 5 months ago

I opened this issue in their community forum as well and they said that they don't yet support connecting to Windows or macOS machines. I guess it was lucky that it worked in the beginning.

https://forum.cursor.sh/t/ssh-still-not-working/722/2