title: Specifying SSH key for JGit
body: <p>I'm wondering how I can use jgit to connect to github using a specified ssh key file (i.e. one not in <code>~/.ssh/</code>).</p>
  
  <p>Unfortunately, I'm not sure how to use <code>JschConfigSessionFactory</code> properly. I've tried creating a setup just like the one in this article: <a href="https://stackoverflow.com/questions/13686643/using-keys-with-jgit-to-access-a-git-repository-securely">Using Keys with JGit to Access a Git Repository Securely</a></p>
  
  <p>I call git using <code>git.push().setRemote(remotePath).call();</code> However, I get this error (specific repository omitted from log):</p>
  
  <pre class="lang-none prettyprint-override"><code>org.eclipse.jgit.api.errors.TransportException: https://github.com/user/repo: not authorized
      at org.eclipse.jgit.api.PushCommand.call(PushCommand.java:160)
      at gitio.GitInterface.pushToRemote(GitInterface.java:145)
      at engine.GitInterfaceTester.main(GitInterfaceTester.java:25)
  Caused by: org.eclipse.jgit.errors.TransportException: https://github.com/user/repo: not authorized
      at org.eclipse.jgit.transport.TransportHttp.connect(TransportHttp.java:479)
      at org.eclipse.jgit.transport.TransportHttp.openPush(TransportHttp.java:396)
      at org.eclipse.jgit.transport.PushProcess.execute(PushProcess.java:154)
      at org.eclipse.jgit.transport.Transport.push(Transport.java:1173)
      at org.eclipse.jgit.api.PushCommand.call(PushCommand.java:156)
      ... 2 more
  </code></pre>
  
  <p>I've noticed that the custom overriden methods in <code>JschConfigSessionFactory</code> aren't ever actually invoked. This is almost certainly the cause of the problem... but don't know why they're not invoked; I pass the custom <code>JschConfigSessionFactory</code> to <code>SshSessionFactory</code> using <code>SshSessionFactory.setInstance(sessionFactory);</code></p>
  
  <p>Does anybody know what I'm doing wrong?</p>