Note that there are some explanatory texts on larger screens.

plurals
  1. POJGit: Transport Exception - reject HostKey: bitbucket.org
    text
    copied!<p>I am using JGit to create and clone a repository (the remote is a bitbucket repo - and yes, I added my deployment key). In essence, I: </p> <ol> <li>Create repository</li> <li>Disable JSch strict hostkey checking</li> <li>Set JSch credentials (my ssh key is password protected, hence JSch will fail if I don't specify a password)</li> <li>Clone the repository</li> </ol> <p>My code is as follows:</p> <pre><code> // Create repository File gitDir = new File(localPath); FileRepository repo = new FileRepository(gitDir); repo.create(); // Add remote origin SshSessionFactory.setInstance(new JschConfigSessionFactory() { public void configure(Host hc, Session session) { session.setConfig("StrictHostKeyChecking", "no"); } }); JschConfigSessionFactory sessionFactory = new JschConfigSessionFactory() { @Override protected void configure(OpenSshConfig.Host hc, Session session) { CredentialsProvider provider = new CredentialsProvider() { @Override public boolean isInteractive() { return false; } @Override public boolean supports(CredentialItem... items) { return true; } @Override public boolean get(URIish uri, CredentialItem... items) throws UnsupportedCredentialItem { for (CredentialItem item : items) { if (item instanceof CredentialItem.StringType) { ((CredentialItem.StringType) item).setValue("myPassword"); } } return true; } }; UserInfo userInfo = new CredentialsProviderUserInfo(session, provider); session.setUserInfo(userInfo); } }; SshSessionFactory.setInstance(sessionFactory); git = org.eclipse.jgit.api.Git.cloneRepository() .setURI(remote) .setDirectory(new File(localPath + "/git")) .call(); </code></pre> <p>Problem: The clone fails with the following error</p> <blockquote> <p>org.eclipse.jgit.api.errors.TransportException: git@bitbucket.org:username/blah.git: reject HostKey: bitbucket.org at org.eclipse.jgit.api.FetchCommand.call(FetchCommand.java:137) at org.eclipse.jgit.api.CloneCommand.fetch(CloneCommand.java:178) at org.eclipse.jgit.api.CloneCommand.call(CloneCommand.java:125)</p> </blockquote>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload