File tree Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -163,7 +163,25 @@ func (t *sshSmartSubtransport) Action(urlString string, action git2go.SmartServi
163163 addr = fmt .Sprintf ("%s:22" , u .Hostname ())
164164 }
165165
166- t .client , err = ssh .Dial ("tcp" , addr , sshConfig )
166+ // In some scenarios the ssh handshake can hang indefinitely at
167+ // golang.org/x/crypto/ssh.(*handshakeTransport).kexLoop.
168+ //
169+ // xref: https://github.com/golang/go/issues/51926
170+ done := make (chan error , 1 )
171+ go func () {
172+ t .client , err = ssh .Dial ("tcp" , addr , sshConfig )
173+ done <- err
174+ }()
175+
176+ select {
177+ case doneErr := <- done :
178+ if doneErr != nil {
179+ err = fmt .Errorf ("ssh.Dial: %w" , doneErr )
180+ }
181+ case <- time .After (sshConfig .Timeout + (5 * time .Second )):
182+ err = fmt .Errorf ("timed out waiting for ssh.Dial" )
183+ }
184+
167185 if err != nil {
168186 return nil , err
169187 }
You can’t perform that action at this time.
0 commit comments