我正在使用 JGit 将远程 git 存储库克隆为:
Git.cloneRepository().setURI("ssh://[email protected]:8001/myrepo").setDirectory(gitDir).setCredentialsProvider(credentialsProvider).call();
但是,当我这样做时,会出现以下错误:
org.eclipse.jgit.errors.UnsupportedCredentialItem: ssh://[email protected]: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/