【问题标题】:How to add an ed25519 ssh key to eclipse for use with github?如何将 ed25519 ssh 密钥添加到 eclipse 以与 github 一起使用?
【发布时间】:2021-05-16 16:17:27
【问题描述】:

我使用 Git for Windows (v2.30.1) 创建了一个 ed25519 ssh 密钥 ssh-keygen -t ed25519 -C “<github email>” 每个 this github docadded it to my account。我使用ssh -T git@github.com 验证了它可以从 Git CMD 运行。

要将其加载到 Eclipse(v2020-12;EGit v5.11)中,我去了这里:Preferences --> SSH2 --> Key Management --> Load Existing Key...

对于私钥和公钥,我收到此错误failed to load given fileEGit v5.4+ "supports" an ed25519 key,但我找不到关于如何进入 Eclipse 的说明 (expected them here)。谷歌搜索错误没有帮助。

如何在 eclipse 中使用我的 ed25519 密钥?

【问题讨论】:

  • 您是否在 General 选项卡的 General > Network Connections > SSH2 的首选项中添加了私钥(如EGit help/documentation 中所述)?
  • @howlger 你的评论让我更近了一步。我已经在密钥管理选项卡上(已生成 RSA 密钥)并尝试从那里加载现有密钥。在常规选项卡中,我成功添加了我的 ed25519 密钥。现在收到我正在调查的连接错误...

标签: git eclipse github ssh-keys


【解决方案1】:

您不能使用 Load Existing Key 来加载 ssh 密钥似乎很奇怪。我不是唯一犯这个错误的人...感谢 Howlger 指出the relevant doc here。添加密钥的正确方法是在“常规”选项卡中单击Add Private Key… 并选择您的 ed25519 私钥文件(不是以“.pub”结尾的文件)。

我是 git 的新手,所以我在 eclipse GUI(又名 EGit)中尽可能多地使用它。我已经从 Git 的角度克隆了一个公共仓库,如下所示:

  1. 点击Clone a Git Repository and add the clone to this view --> GitHub
  2. 在搜索框中输入 org.aspectj 并单击 Search
  3. 选择 eclipse/org.aspectj 并点击下一步
  4. 选择master分支-->下一步-->进入本地目录
  5. 点击完成

这些步骤很重要,因为 EGit 默认远程 origin 的 repo URI 如下:https://github.com/eclipse/org.aspectj。现在我已经加载了我的 ssh 密钥,我想改变它。所以,还是从 Git 的角度来看,在Remotes 下,我右键单击origin,单击Configure push,然后单击Change… 并单击协议下拉菜单,选择sshFinish。回到Configure push for remote ‘origin’ 窗口,我点击了Save and Push 并得到了这个错误:

Can't connect to any repository: ssh://github.com/eclipse/org.aspectj (ssh://github.com/eclipse/org.aspectj: Cannot log in at github.com:22)

疑难解答终于把我带到了this github documentation about the “git” user。我只需要将 origin 的 URI 更新为 ssh://git@github.com/eclipse/org.aspectj,然后它就可以发挥作用了。

【讨论】:

    【解决方案2】:

    为了测试,请尝试相同的密钥,但不要输入密码。

    错误“failed to load given filewas indeed reported 用于带有密码的密钥(甚至是简单的 id_rsa 密钥)。

    Eclipse issue 326526 提及:

    另一个更简单的解决方法是使用 OpenSSH 删除 (AES) 密码,然后要求(旧)JSch 再次设置相同的密码 - 使用 DES3 (DES seen here)。

    即使 OpenSSH 现在默认使用 AES,它也支持 DES3。使用 DES3,可以在所有代理之间共享相同的密码。不需要 GIT_SSH 变量。经过测试。

    这意味着:

    如果需要,使用密码重新创建您的密钥,但使用旧的 PEM 格式:

    ssh-keygen -m PEM ...
    

    否则你需要use a fork of Jsch

    【讨论】:

    • 不幸的是,这个错误不适用于 EGit 5.11 - 已放弃使用 Jsch 以支持 Apache MINA sshd。
    • @cb4 好的:也许这与 MINA 相关联。
    猜你喜欢
    • 2021-02-23
    • 2016-06-07
    • 2021-05-21
    • 1970-01-01
    • 1970-01-01
    • 2014-07-29
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多