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

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

  •  
  •   purplemystic ·
    pplmx · 89 天前 · 2876 次点击
    这是一个创建于 89 天前的主题,其中的信息可能已经有所发展或是发生改变。

    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
    daxin945
        1
    daxin945  
       89 天前
    是不是密钥失效了?
    Martens
        2
    Martens  
       89 天前
    +1 我也遇到了,还以为是代理的问题
    silverwolf
        3
    silverwolf  
       89 天前
    网上复制的一段我用的代理办法
    <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  
       89 天前
    最近一直这样,我还以为是个例。
    purplemystic
        5
    purplemystic  
    OP
       89 天前
    @daxin945 不行, 重新生成了, 也不行
    silencetea
        6
    silencetea  
       89 天前   ❤️ 2
    jonah
        7
    jonah  
       89 天前
    配置 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
       89 天前
    @Martens 我将能怀疑的都怀疑了一遍, 哈哈
    purplemystic
        9
    purplemystic  
    OP
       89 天前
    @jonah 之前都是可以的, 能够识别代理的
    AresChang
        10
    AresChang  
       89 天前   ❤️ 1
    可能是墙加厚,可以用这个改一下 host ,速度很快。

    https://github.com/521xueweihan/GitHub520
    sunny2580839896
        11
    sunny2580839896  
       89 天前
    +1
    chunqiuyiyu
        12
    chunqiuyiyu  
       89 天前
    在 ~/.ssh/config 中添加如下内容,没有这个文件就新建一个:
    ```
    Host github.com
    Hostname ssh.github.com
    Port 443
    ```
    我是这样解决的。
    XXWHCA
        13
    XXWHCA  
       89 天前   ❤️ 1
    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  
       89 天前
    @purplemystic 我之前不配代理 https 和 ssh 都可以访问的,最近感觉墙厚了 ╮(╯_╰)╭
    licoycn
        15
    licoycn  
       89 天前
    同步一下 hosts 即可: https://github.com/Licoy/fetch-github-hosts
    purplemystic
        16
    purplemystic  
    OP
       89 天前
    @silencetea 按照你给的配置后, 可以生效, 赞
    doco
        17
    doco  
       89 天前
    听说是新加坡的 github 地址有问题, 换美国那边的 vpn 大概率解决问题
    purplemystic
        18
    purplemystic  
    OP
       89 天前
    @doco 不行的, 因为 Copilot 和 ChatGPT 原因, 我一直使用的是美国的
    doco
        19
    doco  
       89 天前   ❤️ 1
    @purplemystic 看一下你连的 github 的 ip 是哪个吧, 20.205.243.166 这个好像不行, 140.82.113.4 这个应该是没问题的
    purplemystic
        20
    purplemystic  
    OP
       89 天前
    @doco 的确是的, 直接这样, 无需设置任何代理, 就是可以工作的

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


    windows 11 ,加入这个配置即可 代理端口 11808 自行替换
    wudx
        31
    wudx  
       89 天前
    直接
    ```
    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  
       89 天前
    @wudx 忽略此回答,没有注意是 ssh 方式...
    wonderfulcxm
        33
    wonderfulcxm  
       89 天前 via iPhone
    就算 ssh ,clash pro 增强模式应该也可以直接走代理吧。
    purplemystic
        34
    purplemystic  
    OP
       89 天前
    @0x723b 这个也是一个解决方法
    nagisaushio
        35
    nagisaushio  
       89 天前 via Android
    用 proxychains 就好了,命令行网不好直接加个前缀
    d4fg4
        37
    d4fg4  
       89 天前 via Android
    机场会屏蔽 22 端口
    danhua
        38
    danhua  
       89 天前
    设置一下 git SSH 代理就可以了,上周也碰见了。通过这个方式可以正常访问了。
    litguy
        39
    litguy  
       89 天前
    早晨试着 clone 了代码
    用 socks5 代理,很快
    BardOS
        40
    BardOS  
       89 天前
    我都是用 bat 自动更新 github520 这个 hosts 文件,速度一直挺快的。
    IvanLi127
        41
    IvanLi127  
       88 天前 via Android
    机场不好。不想换机场节点就试试 ssh over https ,github 有支持。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2944 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 37ms · UTC 14:05 · PVG 22:05 · LAX 07:05 · JFK 10:05
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.