diff --git a/openssh.go b/openssh.go index 10e63fda..811c0142 100644 --- a/openssh.go +++ b/openssh.go @@ -1,6 +1,7 @@ package rig import ( + "bytes" "context" "errors" "fmt" @@ -208,15 +209,16 @@ func (c *OpenSSH) Connect() error { args = append(args, c.args()...) cmd := goexec.Command("ssh", args...) + errBuf := bytes.NewBuffer(nil) cmd.Stdout = nil - cmd.Stderr = nil + cmd.Stderr = errBuf cmd.Stdin = nil log.Debugf("%s: starting ssh control master", c) err := cmd.Run() if err != nil { c.isConnected = false - return fmt.Errorf("failed to start ssh multiplexing control master: %w", err) + return fmt.Errorf("failed to start ssh multiplexing control master: %w (%s)", err, errBuf.String()) } c.isConnected = true