Akhil Prajapati
Akhil Prajapati

Reputation: 1281

Include StrictHostKeyChecking in JGit to clone a git repo

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

Git.cloneRepository().setURI("ssh://[email protected]:8001/myrepo").setDirectory(gitDir).setCredentialsProvider(credentialsProvider).call();

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

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?

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.

Upvotes: 3

Views: 1760

Answers (1)

Akhil Prajapati
Akhil Prajapati

Reputation: 1281

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

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

Upvotes: 4

Related Questions