Skip to content

x/crypto/ssh: connect to centos with cipher aes128-cbc , get an error ssh: handshake failed: ssh: packet too large  #64779

Open
@zouxinjiang

Description

@zouxinjiang

Go version

go1.21.1 windows/amd64

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

set GO111MODULE=
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\xxx\AppData\Local\go-build
set GOENV=C:\Users\xxx\AppData\Roaming\go\env
set GOEXE=.exe
set GOEXPERIMENT=
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=D:\xxx\gopath\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=D:\xxx\gopath
set GOPRIVATE=
set GOPROXY=https://goproxy.cn
set GOROOT=D:\xxx\env\go\install
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLCHAIN=auto
set GOTOOLDIR=D:\xxx\env\go\install\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=go1.21.1
set GCCGO=gccgo
set GOAMD64=v1
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=0
set GOMOD=NUL
set GOWORK=
set CGO_CFLAGS=-O2 -g
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-O2 -g
set CGO_FFLAGS=-O2 -g
set CGO_LDFLAGS=-O2 -g
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -fno-caret-diagnostics -Qunused-arguments -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=C:\Users\xxx\AppData\Local\Temp\go-build1140378664=/tmp/go-build -gno-record-gcc-switches

What did you do?

I want to connect a ssh server (a centos device) with cipher aes128-cbc, but get an error.
my code:

cfg := &ssh.ClientConfig{
    User: "xxx",
    Auth: []ssh.AuthMethod{ssh.Password("xxx")},
    HostKeyCallback: func(hostname string, remote net.Addr, key ssh.PublicKey) error {
        return nil
    },
}

cfg.SetDefaults()

cfg.Ciphers = []string{"aes128-cbc"}
cfg.KeyExchanges = []string{"curve25519-sha256@libssh.org"}

ssh.Dial("tcp", "xxx:22", cfg)

my console output:

panic: ssh: handshake failed: ssh: packet too large

I try to write a ssh server by github.com/gliderlabs/ssh and set the server cipher is aes128-cbc only. then the above code is work。

its looks like different implement for aes128-cbc between golang and other program language。

What did you expect to see?

no any more

What did you see instead?

no any more

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

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions