sshcode icon indicating copy to clipboard operation
sshcode copied to clipboard

Unable to use with Bastion Server (err255)

Open Merith-TK opened this issue 6 years ago • 1 comments

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,
			)
		}
	}

Merith-TK avatar Nov 26 '19 20:11 Merith-TK

@Merith-TK please post logs from sshcode.

deansheather avatar Feb 21 '20 07:02 deansheather