Skip to content

x/crypto/ssh: Why does the timeout parameter only work on tcp establishment? #50046

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
xue8 opened this issue Dec 8, 2021 · 1 comment
Closed

Comments

@xue8
Copy link

xue8 commented Dec 8, 2021

What version of Go are you using (go version)?

$ go version
go version go1.16.6 darwin/arm64

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
warning: GOPATH set to GOROOT (/Users/xuerongyue/soft/golang/go) has no effect
GO111MODULE="on"
GOARCH="arm64"
GOBIN=""
GOCACHE="/Users/xuerongyue/Library/Caches/go-build"
GOENV="/Users/xuerongyue/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="arm64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/xuerongyue/soft/golang/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/xuerongyue/soft/golang/go"
GOPRIVATE=""
GOPROXY="https://goproxy.io,direct"
GOROOT="/Users/xuerongyue/soft/golang/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/Users/xuerongyue/soft/golang/go/pkg/tool/darwin_arm64"
GOVCS=""
GOVERSION="go1.16.6"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/xuerongyue/git/github/bao/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/r_/82trt7cs6v9_njvn04h4lbym0000gn/T/go-build2567262407=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

https://go.dev/play/p/g1fBEI6l9Qp

When using ssh.Dial to establish an ssh connection, if the server network is reachable, but the server fails to send any data to the client because of the server failure, the client hang is left standing, even though the timeout parameter has been set. (See sample code)

Checking the code of x/crypto/ssh shows that the timeout parameter only works in the tcp establishment phase (as shown in the three handshakes), not in the ssh authentication login phase (as shown in the phase outside the three handshakes).

image

For what reason does the timeout setting here not work in the ssh authentication phase?

What did you expect to see?

The timeout parameter works on the ssh establishment.

What did you see instead?

The timeout parameter only works on tcp establishment.

@xue8 xue8 changed the title x/crypto/ssh: Why does the timeout parameter only work on tcp network connections? x/crypto/ssh: Why does the timeout parameter only work on tcp network establishment? Dec 8, 2021
@xue8 xue8 changed the title x/crypto/ssh: Why does the timeout parameter only work on tcp network establishment? x/crypto/ssh: Why does the timeout parameter only work on tcp establishment? Dec 8, 2021
@seankhliao
Copy link
Member

As the docs say https://pkg.go.dev/golang.org/x/crypto/ssh#ClientConfig :

// Timeout is the maximum amount of time for the TCP connection to establish.
//
// A Timeout of zero means no timeout.
Timeout time.Duration

See #26643 (comment)

@golang golang locked and limited conversation to collaborators Dec 8, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants