duan6161 2017-05-30 18:12
浏览 235
已采纳

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 ?

  • 写回答

1条回答 默认 最新

  • duano3557 2017-05-30 18:20
    关注

    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()
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?