V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
mrgeneral
V2EX  ›  macOS

升级 Ventura 导致 Git 认证失败解法

  •  
  •   mrgeneral · 2022-10-25 19:45:24 +08:00 · 1512 次点击
    这是一个创建于 547 天前的主题,其中的信息可能已经有所发展或是发生改变。

    现象:GitHub 正常,但是内网 Git SSH Key 认证失败,无法拉取代码。

    Permission denied (publickey,password).
    fatal: Could not read from remote repository.
    

    开了下 Debug ,定位到问题。

    debug1: send_pubkey_test: no mutual signature algorithm
    debug1: No more authentication methods to try.
    

    因为 Ventura 自带 OpenSSH_9.0p1 而从 8.2 开始 OpenSSH 默认不再支持 ssh-rsa,所以认证失败。

    解法:使用新的算法生成密钥(推荐 ED25519 )或者临时开启 ssh-rsa 支持。

     Host xxxx
     User xxx
     PreferredAuthentications publickey
     HostKeyAlgorithms +ssh-rsa
     PubkeyAcceptedKeyTypes +ssh-rsa
    

    希望对大家有用。

    10 条回复    2023-07-17 12:13:39 +08:00
    CEBBCAT
        1
    CEBBCAT  
       2022-10-25 22:23:49 +08:00   ❤️ 1
    谢谢分享!补充一点细节:被禁用的好像是基于 SHA-1 的 ssh-rsa ,基于 SHA-2 的还 OK 。使用 >=openssh 7.2 ( 2016 发行) 默认生成的 rsa 密钥应该就是它

    补充一下链接
    thttps://www.openssh.com/txt/release-8.2
    rillhu
        2
    rillhu  
       2022-10-26 00:06:13 +08:00
    学习了,暂时好像没遇到 git 失效
    xiyangzh
        3
    xiyangzh  
       2022-10-26 14:53:26 +08:00
    太有用了, 我还一度怀疑是运维同学搞啥了? 原来坑在这里
    xiyangzh
        4
    xiyangzh  
       2022-10-26 14:55:21 +08:00
    Host xxxx
    User xxx
    PreferredAuthentications publickey
    HostKeyAlgorithms +ssh-rsa
    PubkeyAcceptedKeyTypes +ssh-rsa

    这段怎么用呢?
    mrgeneral
        5
    mrgeneral  
    OP
       2022-10-26 15:34:29 +08:00
    @xiyangzh 编辑文件 `~/.ssh/config` 即可
    xiyangzh
        6
    xiyangzh  
       2022-10-26 16:06:22 +08:00
    @mrgeneral 搞定,🙏
    fingle0618
        7
    fingle0618  
       2022-10-26 18:18:13 +08:00
    用 ED25519 重新生成了密钥,还是失败,怎么破
    fingle0618
        8
    fingle0618  
       2022-10-26 18:18:57 +08:00
    @mrgeneral 用 ED25519 重新生成了密钥,添加
    fingle0618
        9
    fingle0618  
       2022-10-26 18:19:45 +08:00
    Host xxxx
    User xxx
    PreferredAuthentications publickey
    HostKeyAlgorithms +ssh-rsa
    PubkeyAcceptedKeyTypes +ssh-rsa
    suisetai
        10
    suisetai  
       282 天前 via iPhone
    非常感谢.. 开的 vps 用密钥一直登不上去 我还以为哪出问题了 一看版本 6.6.1 ….. 解决了困扰许久的问题
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1055 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 22:26 · PVG 06:26 · LAX 15:26 · JFK 18:26
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.