GoLang ssh:尽管将其设置为nil,但仍然出现“必须指定HosKeyCallback”错误

I am trying to connect to a remote server using GoLang. In the client configuration, apart from user and password, I set HostKeyCallback to nil so that it accepts every host

config := &ssh.ClientConfig{

        User: user,

        HostKeyCallback: nil,

        Auth: []ssh.AuthMethod{

        publicKey,
    },
}

But I keep getting this error.

Failed to dial: ssh: must specify HostKeyCallback

How do I solve this ?

The behavior of nil for HostKeyCallback was changed: https://github.com/golang/go/issues/19767

If you want to allow any host:

HostKeyCallback: ssh.InsecureIgnoreHostKey()