diff --git a/sshcode.go b/sshcode.go index 6334f02..f1a0e2f 100644 --- a/sshcode.go +++ b/sshcode.go @@ -56,9 +56,9 @@ func sshCode(host, dir string, o options) error { dlScript := downloadScript(codeServerPath) // Downloads the latest code-server and allows it to be executed. - sshCmdStr := fmt.Sprintf("ssh %v %v '/usr/bin/env bash'", o.sshFlags, host) + sshCmdStr := fmt.Sprintf("ssh %v %v '/usr/bin/env bash -l'", o.sshFlags, host) - sshCmd := exec.Command("sh", "-c", sshCmdStr) + sshCmd := exec.Command("sh", "-l", "-c", sshCmdStr) sshCmd.Stdout = os.Stdout sshCmd.Stderr = os.Stderr sshCmd.Stdin = strings.NewReader(dlScript) @@ -99,7 +99,7 @@ func sshCode(host, dir string, o options) error { ) // Starts code-server and forwards the remote port. - sshCmd = exec.Command("sh", "-c", sshCmdStr) + sshCmd = exec.Command("sh", "-l", "-c", sshCmdStr) sshCmd.Stdin = os.Stdin sshCmd.Stdout = os.Stdout sshCmd.Stderr = os.Stderr @@ -397,7 +397,7 @@ func parseHost(host string) (parsedHost string, additionalFlags string, err erro func parseGCPSSHCmd(instance string) (ip, sshFlags string, err error) { dryRunCmd := fmt.Sprintf("gcloud compute ssh --dry-run %v", instance) - out, err := exec.Command("sh", "-c", dryRunCmd).CombinedOutput() + out, err := exec.Command("sh", "-l", "-c", dryRunCmd).CombinedOutput() if err != nil { return "", "", xerrors.Errorf("%s: %w", out, err) } diff --git a/sshcode_test.go b/sshcode_test.go index fc6eb7d..096bff6 100644 --- a/sshcode_test.go +++ b/sshcode_test.go @@ -48,7 +48,7 @@ func TestSSHCode(t *testing.T) { waitForSSHCode(t, remotePort, time.Second*30) // Typically we'd do an os.Stat call here but the os package doesn't expand '~' - out, err := exec.Command("sh", "-c", "stat "+codeServerPath).CombinedOutput() + out, err := exec.Command("sh", "-l", "-c", "stat "+codeServerPath).CombinedOutput() require.NoError(t, err, "%s", out) out, err = exec.Command("pkill", filepath.Base(codeServerPath)).CombinedOutput() @@ -200,7 +200,7 @@ func handleSession(ch ssh.Channel, in <-chan *ssh.Request, t *testing.T) { return } - cmd := exec.Command("sh", "-c", exReq.Command) + cmd := exec.Command("sh", "-l", "-c", exReq.Command) stdin, err := cmd.StdinPipe() require.NoError(t, err)