Eclipse:加载 SSH2 私钥时出错

zer*_*_yu 3 eclipse ssh

我在 macOS Mojave 版本 10.14.1 上使用 eclipse 版本:2018-12 (4.10.0)。我按照https://help.github.com/enterprise/2.9/user/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent/上的说明进行设置GitHub 的 ssh 密钥。我可以毫无问题地在终端中“git clone”存储库。但是,到了eclipse的时候,出现了异常:

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
Run Code Online (Sandbox Code Playgroud)

我确定 URI 是正确的。我的 ~/.ssh/congif 是

Host *
 AddKeysToAgent yes
 UseKeychain yes
 IdentityFile ~/.ssh/id_rsa
Run Code Online (Sandbox Code Playgroud)

有人可以帮我吗?

how*_*ger 5

确保在Window > Preferences: General > Network Connections > SSH2选项卡General that Private keys contains id_rsa

由于Eclipse 2018-12(其中包含JGit /例如:It 5.2),你可以在尝试窗口>首选项:团队>的Git切换SSH客户端JSch Apache的MINA的sshd看到这段视频显示它)。