From 6b67483cc9e5bc5323792140067f02e74bbc6c69 Mon Sep 17 00:00:00 2001 From: Kimmo Lehto Date: Wed, 7 Feb 2024 10:50:08 +0200 Subject: [PATCH] control master logging Signed-off-by: Kimmo Lehto --- openssh.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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