Skip to content

Commit 5dbbf13

Browse files
committed
Include remote error when pure SSH protocol fails
Right now, if spawning the remote command fails for some reason, we get a message like the following in the trace output: pure SSH protocol connection failed: Unable to negotiate version with remote side (unable to read capabilities): EOF However, all we know is that we failed to connect to the remote `git-lfs-transfer` process. That could be for any number of reasons: the remote program doesn't exist or is not in `PATH`, the user has misconfigured something locally or remotely, or any number of other problems. We won't know unless we log the output, so let's do that so we can get more information.
1 parent 59194ad commit 5dbbf13

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

ssh/connection.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
package ssh
22

33
import (
4+
"bytes"
5+
"fmt"
46
"sync"
57

68
"github.com/git-lfs/git-lfs/v3/config"
9+
"github.com/git-lfs/git-lfs/v3/errors"
710
"github.com/git-lfs/git-lfs/v3/subprocess"
11+
"github.com/git-lfs/git-lfs/v3/tr"
812
"github.com/git-lfs/pktline"
913
"github.com/rubyist/tracerx"
1014
)
@@ -39,6 +43,7 @@ func NewSSHTransfer(osEnv config.Environment, gitEnv config.Environment, meta *S
3943

4044
func startConnection(id int, osEnv config.Environment, gitEnv config.Environment, meta *SSHMetadata, operation string, multiplexControlPath string) (conn *PktlineConnection, multiplexing bool, controlPath string, err error) {
4145
tracerx.Printf("spawning pure SSH connection")
46+
var errbuf bytes.Buffer
4247
exe, args, multiplexing, controlPath := GetLFSExeAndArgs(osEnv, gitEnv, meta, "git-lfs-transfer", operation, true, multiplexControlPath)
4348
cmd, err := subprocess.ExecCommand(exe, args...)
4449
if err != nil {
@@ -52,6 +57,7 @@ func startConnection(id int, osEnv config.Environment, gitEnv config.Environment
5257
if err != nil {
5358
return nil, false, "", err
5459
}
60+
cmd.Stderr = &errbuf
5561
err = cmd.Start()
5662
if err != nil {
5763
return nil, false, "", err
@@ -74,6 +80,7 @@ func startConnection(id int, osEnv config.Environment, gitEnv config.Environment
7480
r.Close()
7581
w.Close()
7682
cmd.Wait()
83+
err = errors.Combine([]error{err, fmt.Errorf(tr.Tr.Get("Failed to connect to remote SSH server: %s", cmd.Stderr))})
7784
}
7885
tracerx.Printf("pure SSH connection successful")
7986
return conn, multiplexing, controlPath, err

0 commit comments

Comments
 (0)