gpt4 book ai didi

java - 在 JGit 中包含 StrictHostKeyChecking 来克隆 git 存储库

转载 作者:行者123 更新时间:2023-12-02 02:19:54 25 4
gpt4 key购买 nike

我正在使用 JGit 将远程 git 存储库克隆为:

Git.cloneRepository().setURI("ssh://krisv@10.1.5.32:8001/myrepo").setDirectory(gitDir).setCredentialsProvider(credentialsProvider).call();

但是,当我这样做时,会出现以下错误:

org.eclipse.jgit.errors.UnsupportedCredentialItem: ssh://user@10.1.9.1:8001: org.eclipse.jgit.transport.CredentialItem$YesNoType:The authenticity of host '10.1.9.1' can't be established. DSA key fingerprint is "some value". Are you sure you want to continue connecting?

现在我不想提示此消息,并且我想通过默认提供来绕过此消息。然而,我在 JGit 中没有得到任何这样的选项。

ssh 中有一个选项:StrictHostKeyChecking,我们可以用它来绕过这个问题。我们有什么方法可以在 JGit 中使用这个选项吗?或者还有其他方法可以达到同样的效果吗?

请帮忙。谢谢。

最佳答案

最后,我成功实现了这个功能。我添加了以下代码并且它起作用了:

JSch.setConfig("StrictHostKeyChecking", "no");

关于java - 在 JGit 中包含 StrictHostKeyChecking 来克隆 git 存储库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48660083/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com