coder / sshcode

Run VS Code on any server over SSH.
MIT License
5.74k stars 216 forks source link

Unable to use with Bastion Server (err255) #153

Open Merith-TK opened 4 years ago

Merith-TK commented 4 years ago

the bastion server in question is (sshPortal)[https://github.com/moul/sshportal]

something in this chunk of code in sshcode.go errors out with Error Code 255 Dont know exactly what is causing it, but my therory is it is trying to do things on the bastionserver before it is proxied across to the target,

To reproduce, do the following install sshportal "invite" a new user, and add a host,

create invite <email, can be false>
# read the readme of the program for how to do so
host create user@host:port --name <hostname, can be anything>

then ssh through sshportal to the host, to verify it is configured properly ssh <hostname>@portal -p 2222 Then test sshcode to verify this issue sshcode --skipsync --ssh-flags "-p 2222" <hostname>@portal

If you are unable to reproduce this issue, go ahead and close this

    if o.uploadCodeServer != "" {
        flog.Info("uploading local code-server binary...")
        err = copyCodeServerBinary(o.sshFlags, host, o.uploadCodeServer, codeServerPath)
        if err != nil {
            return xerrors.Errorf("failed to upload local code-server binary to remote server: %w", err)
        }

        sshCmdStr :=
            fmt.Sprintf("ssh %v %v 'chmod +x %v'",
                o.sshFlags, host, codeServerPath,
            )

        sshCmd := exec.Command("sh", "-l", "-c", sshCmdStr)
        sshCmd.Stdout = os.Stdout
        sshCmd.Stderr = os.Stderr
        err = sshCmd.Run()
        if err != nil {
            return xerrors.Errorf("failed to make code-server binary executable:\n---ssh cmd---\n%s: %w",
                sshCmdStr,
                err,
            )
        }
    } else {
        flog.Info("ensuring code-server is updated...")
        dlScript := downloadScript(codeServerPath)

        // Downloads the latest code-server and allows it to be executed.
        sshCmdStr := fmt.Sprintf("ssh %v %v '/usr/bin/env bash -l'", o.sshFlags, host)

        sshCmd := exec.Command("sh", "-l", "-c", sshCmdStr)
        sshCmd.Stdout = os.Stdout
        sshCmd.Stderr = os.Stderr
        sshCmd.Stdin = strings.NewReader(dlScript)
        err = sshCmd.Run()
        if err != nil {
            return xerrors.Errorf("failed to update code-server:\n---ssh cmd---\n%s"+
                "\n---download script---\n%s: %w",
                sshCmdStr,
                dlScript,
                err,
            )
        }
    }
deansheather commented 4 years ago

@Merith-TK please post logs from sshcode.