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

Mac终端Eclipse中无法通过SSH密钥推送至GitHub问题求助

问题原因与解决办法

错误原因

你遇到的nodename nor servname provided错误,是因为错误地将完整的Git SSH仓库地址作为SSH命令的主机名。SSH仅识别github.com为目标主机,后面的alexandranes/demo-repo.git是仓库路径,不能跟在主机名后作为SSH的连接目标。

解决步骤

  • 检查并修正Git远程仓库地址
    先执行命令查看当前远程地址:

    git remote -v
    

    如果地址配置错误,用以下命令设置正确的SSH远程地址:

    git remote set-url origin git@github.com:alexandranes/demo-repo.git
    
  • 正确测试SSH与GitHub的连接
    不要带仓库路径,执行专门的SSH验证命令:

    ssh -T git@github.com
    

    成功连接会返回类似提示:Hi alexandranes! You've successfully authenticated, but GitHub does not provide shell access.

  • 推送代码的正确命令
    确认要推送的分支后,执行:

    git push origin <你的分支名>
    

    例如推送main分支:

    git push origin main
    

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.12 19:52:02