最近无法通过 ssh 方式 clone github 项目 - V2EX
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
purplemystic
V2EX    GitHub

最近无法通过 ssh 方式 clone github 项目

  •  
  •   purplemystic
    pplmx 2024-01-29 09:27:43 +08:00 4046 次点击
    这是一个创建于 693 天前的主题,其中的信息可能已经有所发展或是发生改变。

    failed to clone repo by ssh

    image.png

    有人遇到么,

    • github 调整了什么策略么?
    • 还是 clash 出现 bug 了, 导致无法 ssh 方式无法走代理?
    • 或者 git 出现 bug 了, git version: git version 2.43.0.windows.1
    41 条回复    2024-01-30 09:11:50 +08:00
    haoyunyinglai
        1
    haoyunyinglai  
       2024-01-29 09:30:06 +08:00
    是不是密钥失效了?
    Martens
        2
    Martens  
       2024-01-29 09:33:06 +08:00
    +1 我也遇到了,还以为是代理的问题
    silverwolf
        3
    silverwolf  
       2024-01-29 09:33:50 +08:00
    网上复制的一段我用的代理办法
    <pre>
    # ~/.ssh/config
    Host github.com
    Hostname github.com
    ServerAliveInterval 55
    ForwardAgent yes
    ProxyCommand nc -x 127.0.0.1:10808 %h %p
    </pre>
    vicalloy
        4
    vicalloy  
       2024-01-29 09:35:27 +08:00
    最近一直这样,我还以为是个例。
    purplemystic
        5
    purplemystic  
    OP
       2024-01-29 09:36:09 +08:00
    @daxin945 不行, 重新生成了, 也不行
    silencetea
        6
    silencetea  
       2024-01-29 09:36:12 +08:00   2
    jonah
        7
    jonah  
       2024-01-29 09:37:04 +08:00
    配置 http.proxy 对 SSH 不起作用,SSH 需要单独配置。

    [Git 使用 SSH 传输协议的代理方法
    ]( https://ericclose.github.io/git-proxy-config.html#Git-%E4%BD%BF%E7%94%A8-SSH-%E4%BC%A0%E8%BE%93%E5%8D%8F%E8%AE%AE%E7%9A%84%E4%BB%A3%E7%90%86%E6%96%B9%E6%B3%95)
    purplemystic
        8
    purplemystic  
    OP
       2024-01-29 09:37:31 +08:00
    @Martens 我将能怀疑的都怀疑了一遍, 哈哈
    purplemystic
        9
    purplemystic  
    OP
       2024-01-29 09:38:37 +08:00
    @jonah 之前都是可以的, 能够识别代理的
    AresChang
        10
    AresChang  
       2024-01-29 09:38:50 +08:00   1
    可能是墙加厚,可以用这个改一下 host ,速度很快。

    https://github.com/521xueweihan/GitHub520
    sunny2580839896
        11
    sunny2580839896  
       2024-01-29 09:40:19 +08:00
    +1
    chunqiuyiyu
        12
    chunqiuyiyu  
       2024-01-29 09:40:34 +08:00
    在 ~/.ssh/config 中添加如下内容,没有这个文件就新建一个:
    ```
    Host github.com
    Hostname ssh.github.com
    Port 443
    ```
    我是这样解决的。
    XXWHCA
        13
    XXWHCA  
       2024-01-29 09:41:39 +08:00   2
    ssh 代理需要单独配置
    ```
    cat .ssh/config
    Host github.com
    Hostname ssh.github.com
    IdentityFile /Users/xxx/.ssh/id_ed25519
    User git
    Port 443
    ProxyCommand nc -v -x 127.0.0.1:7890 %h %p
    ```
    jonah
        14
    jonah  
       2024-01-29 09:41:53 +08:00
    @purplemystic 我之前不配代理 https 和 ssh 都可以访问的,最近感觉墙厚了 (_)
    licoycn
        15
    licoycn  
       2024-01-29 09:42:38 +08:00
    同步一下 hosts 即可: https://github.com/Licoy/fetch-github-hosts
    purplemystic
        16
    purplemystic  
    OP
       2024-01-29 09:43:56 +08:00
    @silencetea 按照你给的配置后, 可以生效, 赞
    doco
        17
    doco  
       2024-01-29 09:45:44 +08:00
    听说是新加坡的 github 地址有问题, 换美国那边的 vpn 大概率解决问题
    purplemystic
        18
    purplemystic  
    OP
       2024-01-29 09:47:17 +08:00
    @doco 不行的, 因为 Copilot 和 ChatGPT 原因, 我一直使用的是美国的
    doco
        19
    doco  
       2024-01-29 09:52:57 +08:00   1
    @purplemystic 看一下你连的 github 的 ip 是哪个吧, 20.205.243.166 这个好像不行, 140.82.113.4 这个应该是没问题的
    purplemystic
        20
    purplemystic  
    OP
       2024-01-29 10:00:09 +08:00
    @doco 的确是的, 直接这样, 无需设置任何代理, 就是可以工作的

    > git clone [email protected]:x-pt/template.git
    MrQSJ
        21
    MrQSJ  
       2024-01-29 10:03:24 +08:00
    可以换成 https ,我遇到之后用 https+代理,通过了
    crysislinux
        22
    crysislinux  
       2024-01-29 10:06:07 +08:00 via Android
    我的没问题,走的香港。不过 github 本身也是推荐用 https ,你就换 https 好了。
    purplemystic
        23
    purplemystic  
    OP
       2024-01-29 10:07:03 +08:00
    @crysislinux 不是应该推荐使用 ssh 方式么?
    Alliot
        24
    Alliot  
       2024-01-29 10:21:53 +08:00 via Android
    https://www.iots.vip/post/elegant-solution-git-multiple-accounts-proxy-issues.html 可以参考一下
    villivateur
        25
    villivateur  
       2024-01-29 10:22:02 +08:00
    Alliot
        26
    Alliot  
       2024-01-29 10:23:13 +08:00 via Android
    @Alliot 文末有附文档 ssh over https
    shelken
        27
    shelken  
       2024-01-29 10:38:39 +08:00   2
    这两天刚好遇到这个问题:
    in `~/.ssh/config`
    ```conf
    Host github.com
    User git
    HostName ssh.github.com
    Port 443
    ```
    0x723b
        28
    0x723b  
       2024-01-29 10:42:47 +08:00   1
    devliu1
        29
    devliu1  
       2024-01-29 10:43:52 +08:00 via Android
    墙了 楼上说过了
    rockxsj
        30
    rockxsj  
       2024-01-29 10:54:53 +08:00


    windows 11 ,加入这个配置即可 代理端口 11808 自行替换
    wudx
        31
    wudx  
       2024-01-29 11:14:05 +08:00
    直接
    ```
    export https_proxy=http://127.0.0.1:7890;export http_proxy=http://127.0.0.1:7890;export all_proxy=socks5://127.0.0.1:7890
    ```
    不就可以了吗
    wudx
        32
    wudx  
       2024-01-29 11:17:46 +08:00
    @wudx 忽略此回答,没有注意是 ssh 方式...
    wonderfulcxm
        33
    wonderfulcxm  
       2024-01-29 11:24:32 +08:00 via iPhone
    就算 ssh ,clash pro 增强模式应该也可以直接走代理吧。
    purplemystic
        34
    purplemystic  
    OP
       2024-01-29 11:27:16 +08:00
    @0x723b 这个也是一个解决方法
    nagisaushio
        35
    nagisaushio  
       2024-01-29 11:30:51 +08:00 via Android
    用 proxychains 就好了,命令行网不好直接加个前缀
    defunct9
        36
    defunct9  
       2024-01-29 11:31:56 +08:00
    d4fg4
        37
    d4fg4  
       2024-01-29 12:38:03 +08:00 via Android
    机场会屏蔽 22 端口
    danhua
        38
    danhua  
       2024-01-29 13:39:03 +08:00
    设置一下 git SSH 代理就可以了,上周也碰见了。通过这个方式可以正常访问了。
    litguy
        39
    litguy  
       2024-01-29 14:16:38 +08:00
    早晨试着 clone 了代码
    用 socks5 代理,很快
    BardOS
        40
    BardOS  
       2024-01-29 15:41:05 +08:00
    我都是用 bat 自动更新 github520 这个 hosts 文件,速度一直挺快的。
    IvanLi127
        41
    IvanLi127  
       2024-01-30 09:11:50 +08:00 via Android
    机场不好。不想换机场节点就试试 ssh over https ,github 有支持。
    关于     帮助文档     自助推广系统     博客     API     FAQ     Solana     924 人在线   最高记录 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 28ms UTC 19:50 PVG 03:50 LAX 11:50 JFK 14:50
    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