-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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: concurrent call ssh.Dial will fail #27140
Comments
|
@meirf 1、That doesn't help me. The single thread, it works fine. 2、Sorry to unclear description.
Or. Should I use a 'lock' to call ssh.Dial then create ssh session to avoid this problem? |
I can't reproduce this. The code is package main
import (
"fmt"
"net"
"time"
"golang.org/x/crypto/ssh"
)
func main() {
auth := []ssh.AuthMethod{ssh.Password("my password")}
config := &ssh.ClientConfig{
User: "my username",
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++ {
i := i
go func() {
client, err := ssh.Dial("tcp", "localhost:22", config)
if err != nil {
fmt.Println(i, err) // the 2th thread (maybe 3th or other litter value) will error
} else {
fmt.Println(i, "success")
client.Close()
}
}()
}
select {}
} And I got
If you can reproduce your problem with my code, please paste the exact output. |
@crvv I think you can try with for i := 0; i < 3; i ++ { // with 3 or more. |
And My server /etc/ssh/sshd_config MaxSession 10 |
/cc @hanwen |
code looks OK to me. You could try to run with the race detector, but can you confirm it fails with all types of SSH servers? |
@hamaxx [root@my-server ssh]# go run -race main.go My env: What I guess is that, client send the ssh package to the server quickly, the server will refuse or discard the package? |
probably. Maybe there is rate limiting for password logins to avoid brute-force attacks? |
@hanwen Although, I should use it with thread safe. Closing this. |
Same problem #32705 when connecting a firewall device. |
/cc @hanwen re-opened this since another user had an issue. Can you PTAL? |
auth fail but returned nothing from server side |
@songtianyi are you saying that client_auth.go#L350 is causing this issue, or just commenting? |
Nope. What i'm pointing out here is the code client_auth.go#L350 does not return any error message when return auth_failed. |
Does this problem have been solved now? Or any other methods to deal with this? |
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?
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 remainthe second thread error , other machines maybe 3 or ...
The text was updated successfully, but these errors were encountered: