Issue
I am using eclipse Version: 2018-12 (4.10.0) on macOS Mojave Version 10.14.1. I followed the instruction on https://help.github.com/enterprise/2.9/user/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent/ to set up ssh keys for GitHub. I am able to "git clone" the repository in the terminal with no problem. However, when it came to eclipse, an exception occurred:
org.eclipse.jgit.api.errors.TransportException: git@github.***.com:EA/entity-matching.git: invalid private key: [B@47822527
at org.eclipse.jgit.api.LsRemoteCommand.execute(LsRemoteCommand.java:222)
at org.eclipse.jgit.api.LsRemoteCommand.call(LsRemoteCommand.java:161)
at org.eclipse.egit.core.op.ListRemoteOperation.run(ListRemoteOperation.java:116)
at org.eclipse.egit.ui.internal.clone.SourceBranchPage$8.run(SourceBranchPage.java:340)
at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:122)
Caused by: org.eclipse.jgit.errors.TransportException: git@github.***.com:EA/entity-matching.git: invalid privatekey: [B@47822527
at org.eclipse.jgit.transport.JschConfigSessionFactory.getSession(JschConfigSessionFactory.java:191)
at org.eclipse.jgit.transport.SshTransport.getSession(SshTransport.java:140)
at org.eclipse.jgit.transport.TransportGitSsh$SshFetchConnection.<init>(TransportGitSsh.java:280)
at org.eclipse.jgit.transport.TransportGitSsh.openFetch(TransportGitSsh.java:170)
at org.eclipse.jgit.api.LsRemoteCommand.execute(LsRemoteCommand.java:200)
... 4 more
Caused by: com.jcraft.jsch.JSchException: invalid privatekey: [B@47822527
at com.jcraft.jsch.KeyPair.load(KeyPair.java:664)
at com.jcraft.jsch.KeyPair.load(KeyPair.java:561)
at com.jcraft.jsch.IdentityFile.newInstance(IdentityFile.java:40)
at com.jcraft.jsch.JSch.addIdentity(JSch.java:407)
at com.jcraft.jsch.JSch.addIdentity(JSch.java:367)
at org.eclipse.jgit.transport.JschConfigSessionFactory.getJSch(JschConfigSessionFactory.java:399)
at org.eclipse.egit.core.EclipseSshSessionFactory.createSession(EclipseSshSessionFactory.java:53)
at org.eclipse.jgit.transport.JschConfigSessionFactory.createSession(JschConfigSessionFactory.java:208)
at org.eclipse.jgit.transport.JschConfigSessionFactory.getSession(JschConfigSessionFactory.java:138)
... 8 more
I am sure the URI is correct. My ~/.ssh/congif is
Host *
AddKeysToAgent yes
UseKeychain yes
IdentityFile ~/.ssh/id_rsa
Can anybody help me on this please?
Solution
Make sure, in Window > Preferences: General > Network Connections > SSH2 in the tab General that Private keys contains id_rsa
.
Since Eclipse 2018-12 (which contains JGit/EGit 5.2) you can try in Window > Preferences: Team > Git to switch the SSH client from JSch to Apache MINA sshd (see this video showing it).
Answered By - howlger