GoLang ssh: getting a "Must specify HosKeyCallback" error, even though

I am trying to connect to a remote server using GoLang. In the client configuration, in addition to the user and password, I set HostKeyCallback to zero 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 to solve this?

+4
source share
1 answer

Changed nil behavior for HostKeyCallback: https://github.com/golang/go/issues/19767

If you want to allow any host:

HostKeyCallback: ssh.InsecureIgnoreHostKey()
+5
source

Source: https://habr.com/ru/post/1678193/


All Articles