dongtaihui5131
2014-06-25 09:55
浏览 85
已采纳

如何在Go中使用go.crypto / ssh包与StrictHostKeyChecking一起使用?

So far with the ssh package in go I have been able to create some sort of client that will allow two forms of authentication. Either the user inputs a password or it will use keys to authenticate. This works great, however StrictHostKeyChecking may be causing an issue. Normally the first time you would SSH into a remote you'll be prompted with a message asking about the host authorization.

Is there anyway in Go to provide the user with that yes / no prompt or to disable StrictHostKeyChecking altogether?

图片转代码服务由CSDN问答提供 功能建议

到目前为止,使用 ssh包可以创建一种允许两种形式的身份验证的客户端。 用户输入密码,否则它将使用密钥进行身份验证。 这很好用,但是 StrictHostKeyChecking 可能会引起问题。 通常,第一次使用SSH进入远程服务器时,系统会提示您询问主机授权的信息。

Go中仍然存在向用户提供该 yes / no 提示或完全禁用 StrictHostKeyChecking

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • dongtan3306 2014-06-25 10:33
    已采纳

    They don't implement this for you, but you could provide HostKeyCallback in the ClientConfig struct passed to Dial. The function you provide should validate the hostname and host key against some known list and prompt the user if it doesn't match. The documentation says that the default is to accept all host keys, which is like setting StrictHostKeyChecking no in the ssh client config.

    已采纳该答案
    打赏 评论

相关推荐 更多相似问题