2

I am using JGit to clone a remote git repo as:

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

However, when I do so, it gives me the following error:

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?

Now I don't want this message to prompt and I want to bypass this by providing Yes by default. However, I am not getting any such option in JGit.

There is an option in ssh: StrictHostKeyChecking with which we can bypass this. Is there any way by which we can use this option in JGit? Or any other way to achieve the same?

Please help. Thanks.

Akhil Prajapati
  • 1,221
  • 3
  • 14
  • 23
  • Did you look at this post: https://stackoverflow.com/questions/33998477/set-ssl-verification-off-for-jgit-clone-command – Rüdiger Herrmann Feb 07 '18 at 12:52
  • Possible duplicate of [Turn SSL verification off for JGit clone command](https://stackoverflow.com/questions/33998477/turn-ssl-verification-off-for-jgit-clone-command) – Rüdiger Herrmann Feb 08 '18 at 09:46

1 Answers1

4

Finally, I was able to get this working. I added the following code and it worked:

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

Akhil Prajapati
  • 1,221
  • 3
  • 14
  • 23