diff --git a/internal/client/connection_ssh.go b/internal/client/connection_ssh.go index c7baa18..cf57f95 100644 --- a/internal/client/connection_ssh.go +++ b/internal/client/connection_ssh.go @@ -94,11 +94,10 @@ func (s *SSHConnection) Command(cmdLine []string) ([]byte, error) { return nil, fmt.Errorf("ssh: cannot create command '%s' for host '%s': %w", strings.Join(cmdLine, " "), s.host, err) } out, err := cmd.CombinedOutput() - if err != nil { - if len(out) > 0 { - return nil, fmt.Errorf("ssh: cannot run command '%s': %w\n\n%s", cmd, err, string(out)) - } - return nil, err + if err != nil && len(out) > 0 { + return nil, fmt.Errorf("ssh: cannot run command '%s': %w\n\n%s", cmd, err, string(out)) + } else if err != nil { + return nil, fmt.Errorf("ssh: cannot run command '%s': %w", cmd, err) } return out, nil }