Skip to content

x/crypto/ssh: concurrent call ssh.Dial will fail #27140

Open
@wangwd1991

Description

@wangwd1991

Please answer these questions before submitting your issue. Thanks!

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

1.8.3

Does this issue reproduce with the latest release?

https://github.com/golang/crypto.git
commit : 614d502

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

centos 7

What did you do?

auth := make([]ssh.AuthMethod, 0)
auth = append(auth, ssh.Password("123456"))
config := &ssh.ClientConfig {
	User: "root",
	Auth: auth,
	HostKeyCallback: func(hostname string, remote net.Addr, key ssh.PublicKey) error {
		return nil
	},
	Timeout: 30 * time.Second,
}
for i:=0;i<2;i++ {
	go func() {
		client, err := ssh.Dial("tcp", "ip:port", config)
		fmt.Println(err) // the 2th thread (maybe 3th or other litter value) will error
		time.Sleep(5 * time.Second)
		// error is not here, it just a test code
		client.Close()
	}()
}

What did you expect to see?

run pass

What did you see instead?

ssh: handshake failed: ssh: unable to authenticate, attempted methods [none password], no supported methods remain

the second thread error , other machines maybe 3 or ...

Metadata

Metadata

Assignees

No one assigned

    Labels

    NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions