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: occasional handshake failures #32705

Closed
songtianyi opened this issue Jun 20, 2019 · 1 comment
Closed

x/crypto/ssh: occasional handshake failures #32705

songtianyi opened this issue Jun 20, 2019 · 1 comment
Milestone

Comments

@songtianyi
Copy link

@songtianyi songtianyi commented Jun 20, 2019

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

go version go1.12.5 linux/amd64

Does this issue reproduce with the latest release?

YES

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

go env Output
GOARCH="amd64"
GOBIN=""
GOCACHE="/root/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/root/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/lib/golang"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/golang/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build080045227=/tmp/go-build -gno-record-gcc-switches"

What did you do?

package main

import (
        "fmt"
        cssh "golang.org/x/crypto/ssh"
        "time"
)

func main() {
        tick := time.Tick(1 * time.Second)
        for {
                select {
                case <-tick:
                        if err := connect(); err != nil {
                                fmt.Println(err)
                        } else {
                                fmt.Println("SUCCEED")
                        }
                }
        }
}
func connect() error {
        sshConfig := &cssh.ClientConfig{
                User:            "xxxx",
                Auth:            []cssh.AuthMethod{cssh.Password("xxxx")},
                HostKeyCallback: cssh.InsecureIgnoreHostKey(),
                Timeout:         5 * time.Second,
        }
        sshConfig.SetDefaults()
        sshConfig.Ciphers = append(sshConfig.Ciphers, "aes128-cbc")

        conn, err := cssh.Dial("tcp", "172.21.87.229:22", sshConfig)
        if err != nil {
                return err
        }
        defer conn.Close()

        session, err := conn.NewSession()
        if err != nil {
                return fmt.Errorf("new ssh session failed, %s", err)
        }
        // get stdout and stdin channel
        _, err = session.StdoutPipe()
        if err != nil {
                return fmt.Errorf("create stdout pipe failed, %s", err)
        }
        _, err = session.StdinPipe()
        if err != nil {
                return fmt.Errorf("create stdin pipe failed, %s", err)
        }
        modes := cssh.TerminalModes{
                cssh.ECHO: 1, // enable echoing
        }
        if err := session.RequestPty("vt100", 0, 2000, modes); err != nil {
                return fmt.Errorf("request pty failed, %s", err)
        }
        // open channel
        if err := session.Shell(); err != nil {
                return fmt.Errorf("create shell failed, %s", err)
        }
        defer session.Close()
        return nil

}

What did you expect to see?

All connect attempts SUCCEED

What did you see instead?

In small probability, the output has the following error

ssh: handshake failed: ssh: unable to authenticate, attempted methods [none password], no supported methods remain
@gopherbot gopherbot added this to the Unreleased milestone Jun 20, 2019
@katiehockman katiehockman changed the title x/crypto: ssh: handshake failed: ssh: unable to authenticate, attempted methods [none password], no supported methods remain x/crypto/ssh: occasional handshake failures Jun 21, 2019
@katiehockman
Copy link
Member

@katiehockman katiehockman commented Jun 21, 2019

Duplicate of #27140
Let's use the original issue to keep the conversation going there. I'll re-open that. Let me know if you think this is a separate issue that needs addressed.

@golang golang locked and limited conversation to collaborators Jun 23, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.