Skip to content
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

x/crypto/ssh: cannot close ssh session #52290

Open
XindaH opened this issue Apr 12, 2022 · 3 comments
Open

x/crypto/ssh: cannot close ssh session #52290

XindaH opened this issue Apr 12, 2022 · 3 comments
Labels
NeedsInvestigation
Milestone

Comments

@XindaH
Copy link

@XindaH XindaH commented Apr 12, 2022

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

$ go version
1.17

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
GO111MODULE="on"
GOARCH="amd64"
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOPRIVATE=""
GOPROXY="https://goproxy.cn,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GOVCS=""
GOVERSION="go1.17.6"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
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 x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/jx/d_08_gm93psc4v9lm3zzjc300000gn/T/go-build1736071007=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

func test() {
	client, err := ssh.Dial("tcp", "xx.xx.xx.xx:22", &ssh.ClientConfig{
		User:            "root",
		Auth:            []ssh.AuthMethod{ssh.Password("123")},
		HostKeyCallback: ssh.InsecureIgnoreHostKey(),
	})
	if err != nil {
		log.Panic(err)
	}
	session, err := client.NewSession()
	if err != nil {
		log.Panic(err)
	}
	defer session.Close()
	go func() {
		// err := session.Run("while true;do echo test;done")
		err := session.Run("sleep 6000")
		if err != nil {
			log.Println(err)
		}
	}()
	time.Sleep(time.Second * 5)

	err = session.Close()
	if err != nil {
		log.Println(err)
	}
	log.Println("finished")
}

What did you expect to see?

2022/04/12 13:35:17 finished
2022/04/12 13:35:17 Process exited with status 141 from signal PIPE

What did you see instead?

2022/04/12 13:35:17 finished

If I run while true;do echo test;done, the session can be closed gracefully. However sleep 6000 is still running after this process finished.

@gopherbot gopherbot added this to the Unreleased milestone Apr 12, 2022
@ianlancetaylor
Copy link
Contributor

@ianlancetaylor ianlancetaylor commented Apr 12, 2022

This looks related to #23019.

@XindaH
Copy link
Author

@XindaH XindaH commented Apr 13, 2022

This looks related to #23019.

maybe different👀

@dmitshur dmitshur changed the title x/crypto: Cannot close ssh session x/crypto/ssh: cannot close ssh session Apr 14, 2022
@dmitshur dmitshur added the NeedsInvestigation label Apr 14, 2022
@dmitshur
Copy link
Contributor

@dmitshur dmitshur commented Apr 14, 2022

CC @FiloSottile.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsInvestigation
Projects
None yet
Development

No branches or pull requests

4 participants