gitee ssh 抽风了嘛 - V2EX
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
请不要在回答技术问题时复制粘贴 AI 生成的内容
Wanerlove
V2EX    程序员

gitee ssh 抽风了嘛

  •  
  •   Wanerlove 2021-10-16 23:46:31 +08:00 3419 次点击
    这是一个创建于 1460 天前的主题,其中的信息可能已经有所发展或是发生改变。

    上个月还好好的,今天 push 一下提示 ssh 无权限

    [email protected]: Permission denied (publickey). fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists. 

    你们 gitee 还能正常使用嘛

    17 条回复    2021-10-19 14:35:05 +08:00
    proxychains
        1
    proxychains  
       2021-10-17 00:08:55 +08:00
    我配置了多私钥,vps,github 都能用,gitee 一直 permission denied (public key)
    离谱
    Wanerlove
        2
    Wanerlove  
    OP
       2021-10-17 00:13:15 +08:00
    @proxychains gitee 确实辣鸡,同样的这对公私钥,push 到 GitHub 上就能用,我真是想不通
    chengfeng
        3
    chengfeng  
       2021-10-17 00:25:58 +08:00   3
    好像是 openssh 默认不支持 rsa 算法了,可以在 config 文件中加上

    PubkeyAcceptedKeyTypes +ssh-rsa

    但我不知道为什么 github 没问题,就 gitee 抽风,今天也是被这个恶心了好久

    ssh -vT [email protected]

    可以看到
    debug1: Offering public key: (none) RSA SHA256:...k agent
    debug1: send_pubkey_test: no mutual signature algorithm
    Y29tL2gwd2Fy
        4
    Y29tL2gwd2Fy  
       2021-10-17 05:37:02 +08:00 via Android
    国产巅峰 gitcafe 之后再也不想用国内的 git 服务了
    是不是暴露年龄了。。。
    RangerWolf
        5
    RangerWolf  
       2021-10-17 10:42:24 +08:00
    @Y29tL2gwd2Fy 是 因为我也知道 gitcafe ...
    skiy
        6
    skiy  
       2021-10-17 14:09:18 +08:00
    @Y29tL2gwd2Fy 可以尝试 GITLAB 技术入股的极狐 https://gitlab.cn ,不过还得再等一两个月。(我已经申请内测成功了,嘿嘿)
    skiy
        7
    skiy  
       2021-10-17 14:16:15 +08:00   1
    自从上次 README 和 描述中那些正常的中文信息被定义为“非法” 之后,我一直在找国内的替代品,终于等来了 gitlab.cn 。打算以后都将迁移过来了。目前还没公测。社交这块也没做得很好。

    在此期间用过 gitea.com (现在限制只能 5 个仓库数了)、工峰、云效和 CODING 。都是社交方面做得不是很好,比如“优秀的项目推荐”,不容易发现优秀的项目。

    另外,楼主的这种情况我在 gitee 见过,不用处理也解决了。云效这边见过,最后解决方案我记下来了。

    只要在 .ssh/config 添加,即可解决:

    Host *
    PubkeyAcceptedKeyTypes=+ssh-dss
    proxychains
        8
    proxychains  
       2021-10-17 15:05:45 +08:00
    @chengfeng newbee,gitee 能用了.感谢大佬
    Wanerlove
        9
    Wanerlove  
    OP
       2021-10-17 15:15:10 +08:00
    @skiy 好的,非常感谢
    Kobayashi
        10
    Kobayashi  
       2021-10-17 17:27:27 +08:00   1
    @chengfeng 基本是正确的。严格来说不是 RSA 被废弃,RSA 公钥仍然安全,废弃的只是认证过程中的 ssh-rsa 签名格式,或者说哈希算法。

    自从 OpenSSH 7.2,rsa-sha2-* 取代 ssh-rsa 作为默认的 ssh host key algorithm 签名算法。8.2 时通知 ssh-rsa 之后将废弃,8.8 正式废弃了 ssh-rsa.

    https://security.stackexchange.com/a/226133/203193
    > The RFC8332 RSA SHA-2 signature algorithms rsa-sha2-256/512. **These algorithms have the advantage of using the same key type as "ssh-rsa" but use the safe SHA-2 hash algorithms.** These have been supported since OpenSSH 7.2 and are already used by default if the client and server support them.

    另外影响的只是 ssh-rsa hash 算法格式,RSA 公钥(即 id_rsa 文件)仍然使用 ssh-rsa 格式。 因为 RSA 公钥不依赖 hash 函数。

    https://www.ietf.org/rfc/rfc8332.txt
    > Since RSA keys are not dependent on the choice of hash function, the new public key algorithms reuse the "ssh-rsa" public key format as
    defined in [RFC4253]:

    https://superuser.com/a/1488613/733022
    > RSA keys themselves are neither "SHA1" nor "SHA2" - the key format doesn't involve any hash algorithm at all. The private key just consists of two large numbers, and unlike certificates, there is no attached signature.

    https://superuser.com/a/1556861/733022
    > The key format has not changed. The only thing that changes is the signature format that's sent during each authentication handshake.

    ---

    回归原问题,OpenSSH 8.8 客户端默认不提供 ssh-rsa hash function,而远端服务端不接受非 ssh-rsa 外的 rsa-sha2-*. 协商失败。

    目前已知受影响的有 gitee.com, bitbucket.org.

    测试方法: ssh -T [email protected] -vv 或者 ssh -T [email protected]. -vv 开启 debug2 级别日志。在结果中检索 'host key algorithms',注意有 2 条匹配,一条客户端的,一条服务端的。

    gitee: ssh-rsa,ssh-dss,ecdsa-sha2-nistp256,ssh-ed25519. OpenSSH 服务端没有支持 rsa-sha2-*.
    bitbucket 就更狠了: ssh-rsa,ssh-dss. 根本就不支持任何椭圆曲线签名算法。
    Rache1
        11
    Rache1  
       2021-10-17 17:46:38 +08:00
    gitee 比 github 还离谱,老是 push 或者 pull 超时,测试机是 HK 的,有时候拉代码完全听天由命
    Kobayashi
        12
    Kobayashi  
       2021-10-17 18:08:18 +08:00
    更正:

    - bitbucket 还需要指定 HostKeyAlgorithms +ssh-rsa
    - 另外上条回复末尾 bitbucket 不支持椭圆曲线应该是错误的,不能只依据 host key algorithms 判断
    Wanerlove
        13
    Wanerlove  
    OP
       2021-10-17 22:25:27 +08:00
    @Kobayashi 受教了,那么我 .ssh/config 文件写入以下内容就可以吗

    Host gitee.com
    PubkeyAcceptedKeyTypes +ssh-rsa
    HostKeyAlgorithms +ssh-rsa

    还有什么需要修改的,请再指教一下
    knightdf
        14
    knightdf  
       2021-10-18 08:47:14 +08:00
    gitee 这垃圾有用的必要?
    forcecharlie
        15
    forcecharlie  
       2021-10-18 14:29:47 +08:00   4
    gitee 的 SSH 服务使用 Golang 开发,Golang crypto/ssh 没有支持 rsa-sha2-256 rsa-sha2-512 结果就是 openssh 8.8 无法协商,另外 Golang SSH 还不支持 server-sig-algs 扩展,要解决得同时解决两个问题,CODING 也有这个问题,还有 Gitea,都在等 crypto/ssh 的跟进: https://github.com/golang/go/issues/37278

    Github 可能是依然是用的 libssh,但深度定制了。

    其中 maxmanuylov 的 fork 是验证可用的: https://github.com/maxmanuylov/crypto/commit/e400208a17e0c73cc54ae5ef8091b060bcd06d21

    利益相关:Gitee 前员工,SSH 服务器开发者,CODING 前员工。
    qq1340691923
        16
    qq1340691923  
       2021-10-19 09:41:52 +08:00
    @forcecharlie 大佬
    cco
        17
    cco  
       2021-10-19 14:35:05 +08:00
    gitee coding 经常遇到这问题
    关于     帮助文档     自助推广系统     博客     API     FAQ     Solana     966 人在线   最高记录 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 26ms UTC 22:43 PVG 06:43 LAX 15:43 JFK 18:43
    Do have faith in what you're doing.
    ubao msn snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86