You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用Eclipse Git集成时遇"publickey: no more keys to try"错误

Eclipse推送GitLab仓库失败的解决方法

错误信息

Can't connect to any repository: git@gitlab.com:redacted/name.git (git@gitlab.com:redacted/name.git: Cannot log in at gitlab.com:22
publickey: trying ssh-rsa key SHA256:em+KoqJtfIysPRvugiGRHI702T+k4waTv9rh19U5TmM from SSH agent with signature type rsa-sha2-512
publickey: trying ssh-rsa key ~/.ssh/id_rsa with signature type rsa-sha2-512
publickey: trying ssh-rsa key ~/.ssh/id_rsa with signature type rsa-sha2-512
publickey: no more keys to try)

解决步骤

  • 确认SSH2根目录路径
    打开Eclipse的Window > Preferences > General > Network Connections > SSH2,切换到「General」标签,检查「SSH2 home」是否指向你的.ssh目录(Linux/macOS为~/.ssh,Windows为C:\Users\<你的用户名>\.ssh)。如果路径错误,手动选择正确目录,确保Eclipse能找到命名为gitlab的私钥文件。

  • 重新加载私钥并重启Eclipse
    在SSH2配置的「Private Keys」标签下,点击「Add Private Key」,手动选中你的gitlab私钥文件(不要选默认的id_rsa),点击「Apply and Close」后重启Eclipse,让配置生效。

  • 配置Git使用系统SSH命令
    打开Window > Preferences > Team > Git > Configuration,点击「Add Entry」:

    • 键:core.sshCommand
    • 值:ssh
      保存配置,让Eclipse复用系统已配置的SSH代理(你已经通过ssh-add加载了密钥,系统SSH可以正常连通GitLab)。
  • 验证项目远程仓库URL
    右键项目选择Team > Remote > Configure Push to Upstream,确认远程仓库URL与Git CLI使用的git@gitlab.com:redacted/name.git完全一致,若有偏差重新选择正确的远程仓库。

  • 清除Eclipse Git缓存
    关闭Eclipse,找到工作区下的.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.egit.core.prefs文件并删除,重启Eclipse后重新配置Git和SSH相关设置。

内容的提问来源于stack exchange,提问作者shawn_xu

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.14 12:30:07