UnknownHostKey Exception in Accessing GitHub Securely

As this thread is first result to :

com.jcraft.jsch.JSchException: UnknownHostKey: gitservername. RSA key fingerprint"

and the only answer, if the problem persists, is to disable StrictHostKeyChecking, which is not acceptable for security purposes.

If the problem persists, you should have a look to this answer from another thread :

https://stackoverflow.com/a/44777270/13184312

What solved the persisting problem is :

ssh-keyscan -H -t rsa gitservername >> ~/.ssh/known_hosts

It happens because you have no entry for github in ~/.ssh/known_hosts, and JSch used in jgit defaults to rejecting session in this case. Refer to this question for solutions: com.jcraft.jsch.JSchException: UnknownHostKey

To set the ssh session property, you need to create a session factory for jgit:

SshSessionFactory.setInstance(new JschConfigSessionFactory() {
  public void configure(Host hc, Session session) {
    session.setConfig("StrictHostKeyChecking", "no");
  }
})

or add StrictHostKeyChecking=no to ~/.ssh/config