azusachino
V2EX  ›  GitHub

目前国内访问 Github 基本上是不可用状态,请问有没有比较合适的解决办法?

  •  
  •   azusachino ·
    azusachino · Dec 12, 2022 · 6795 views
    This topic created in 1428 days ago, the information mentioned may be changed or developed.
    1. Github 不单单是代码管理,更多的可能是作为社区,或者说,个人简历一样的功能,所以肯定是不能割舍的;
    2. 本地也尝试了使用 socks.proxy 这样的代理模式,但是感觉效果不是很好,git push 还是失效的;

    麻烦大佬指指路,谢谢。

    Supplement 1  ·  Dec 12, 2022
    感谢各位大佬回复,目前,直接改 host 的效果是最好的;因为是公司的电脑,所以软路由就不太合适了;
    随便找了一个 ping 域名找 ip 的工具,这里也贴出来 https://networkappers.com/tools/ping-tool

    [可能是公司这边的 DNS 解析到一个已经死了的 IP 上了?导致 fetch, push 都是 Connection closed]

    至于我本地的 socks 为什么没生效,我再调试调试。🙏
    Supplement 2  ·  Dec 12, 2022
    目前,评论区给出的两款本地代理软件应该是可用的,只是,与我公司的这台电脑有点水土不服吧,不太稳定。

    1. Watt Toolkit - 「 Watt Toolkit 」是一个开源跨平台的多功能 Steam 工具箱。
    地址: https://github.com/BeyondDimension/SteamTools
    2. FastGithub - github 加速神器,解决 github 打不开、用户头像无法加载、releases 无法上传下载、git-clone 、git-pull 、git-push 失败等问题
    地址: https://github.com/dotnetcore/FastGithub
    28 replies  •  2022-12-20 14:10:06 +08:00
    kyric
    kyric
    Dec 12, 2022
    1
    在 git config 里面设置本地 socks 的代理就可以了
    cvbnt
    cvbnt
    Dec 12, 2022 via Android❤️2
    2
    clash tun
    muzihuaner
    muzihuaner
    Dec 12, 2022 via Android
    3
    Steam++
    libook
    libook
    Dec 12, 2022
    4
    我记得 git 好像用的是 curl ,是支持环境变量配置代理的,可以参考我这个工具箱的代码,亲测有效
    https://github.com/libook/IdleBox/blob/master/zshrcs/public/shell-proxy

    根据之前踩过的坑,不同的程序可能对环境变量的大小写敏感,所以我这个里面大小写全都 export 。
    Dvel
    Dvel
    Dec 12, 2022
    5
    我是这么搞的。

    ~/.zshrc 开启 http 代理:
    export https_proxy=http://127.0.0.1:6152
    export http_proxy=http://127.0.0.1:6152
    export all_proxy=socks5://127.0.0.1:6153

    再在 ~/.ssh/config 开启 ssh 代理:
    Host *
    ProxyCommand nc -X 5 -x 127.0.0.1:6153 %h %p


    或者直接增强模式。
    hsfzxjy
    hsfzxjy
    Dec 12, 2022 via Android
    6
    proxychains 一把梭
    Hurriance
    Hurriance
    Dec 12, 2022
    7
    我用过第二种,没有失效的情况,可以检查下是不是其他问题
    bipy
    bipy
    Dec 12, 2022❤️1
    8
    git 两种模式:SSH 、HTTP
    proxy 两种模式:SOCKS 、HTTP

    两两组合,共 4 种设置,请按需正确配置:

    # 1. git http + proxy http
    git config --global http.proxy "http://127.0.0.1:1080"
    git config --global https.proxy "http://127.0.0.1:1080"

    # 2. git http + proxy socks
    git config --global http.proxy "socks5://127.0.0.1:1080"
    git config --global https.proxy "socks5://127.0.0.1:1080"

    # to unset
    git config --global --unset http.proxy
    git config --global --unset https.proxy

    # 3. git ssh + proxy http
    vim ~/.ssh/config
    Host github.com
    HostName github.com
    User git
    ProxyCommand socat - PROXY:127.0.0.1:%h:%p,proxyport=1087

    # 4. git ssh + proxy socks
    vim ~/.ssh/config
    Host github.com
    HostName github.com
    User git
    ProxyCommand nc -v -x 127.0.0.1:1080 %h %p
    arischow
    arischow
    Dec 12, 2022
    9
    0. 能不能路由层翻墙?
    1. 能不能用网关模式 (Surge)? Clash 应该叫 TUN 模式
    yfugibr
    yfugibr
    Dec 12, 2022 via Android❤️1
    10
    Clash 或 Clash.Meta 的 tun 模式很方便
    另外很多机场会屏蔽 22 端口,可以走 443 端口的 ssh
    官方文档 https://docs.github.com/en/authentication/troubleshooting-ssh/using-ssh-over-the-https-port
    herozzm
    herozzm
    Dec 12, 2022❤️1
    11
    host 大法?
    geniusy
    geniusy
    Dec 12, 2022 via Android
    12
    路由器透明代理比较完美
    tf2
    tf2
    Dec 12, 2022
    14
    上一次 github 被封,还是 李开复 在微博上号召大家投诉工信部才解决的。
    20210610204811
    20210610204811
    Dec 12, 2022
    15
    dguge
    dguge
    Dec 12, 2022
    16
    换成 gitee 或 coding
    wdssmq
    wdssmq
    Dec 12, 2022
    17
    Windows 下 SSH 走代理可以这样,socks 协议

    Host github.com
    User git
    ProxyCommand "C:\Program Files\Git\mingw64\bin\connect.exe" -S 127.0.0.1:10808 %h %p
    GeruzoniAnsasu
    GeruzoniAnsasu
    Dec 12, 2022
    18
    proxychains 一把梭 +1
    dzdh
    dzdh
    Dec 12, 2022
    19
    自建 gitea 吧
    yoa1q7y
    yoa1q7y
    Dec 12, 2022
    20
    路由器翻,对墙完全无感
    wxxxcxx
    wxxxcxx
    Dec 12, 2022
    22
    装个 gh ,授权后 git 用 https 协议的仓库就不需要每次都登陆了
    Alan3
    Alan3
    Dec 12, 2022
    23
    在多用户的 linux 下,自用,
    1. 安装好 proxychains
    ```
    alias pc=/path/to/proxychains4
    ```

    2. 启动和关闭脚本 naive,这里代理软件以 naiveproxy 为例子
    ```
    #!/usr/bin/sh
    function rand(){
    min=$1
    max=$(($2-$min+1))
    num=$(date +%s%N)
    echo $(($num%$max+$min))
    }

    rndport=$(rand 20000 60000)

    if [ $1 == "-h" -o $1 == "--help" ];then
    echo '
    ##usage:

    *if u wana proxy via proxychains:
    `naive start`
    then, `proxychains4 command_line`
    `naive stop`
    '
    exit
    fi

    naive_path=/path/to/naiveproxy
    mkdir -p ~/.gofree

    if [ $1 == "start" ];then
    cp $naive_path/config.json ~/.gofree/.json
    cp $naive_path/naive ~/.gofree/fhbfcgdx$rndport
    sed -i "s:1080:$rndport:g" ~/.gofree/.json
    cd ~/.gofree

    ./fhbfcgdx$rndport ~/.gofree/.json > ~/.gofree/log.txt 2>&1 &

    mkdir -p ~/.proxychains/
    echo "[ProxyList]
    socks5 127.0.0.1 $rndport
    " > ~/.proxychains/proxychains.conf

    echo "fhbfcgdx$rndport" >> p.txt

    cd - > /dev/null
    echo "start success!!"
    fi

    if [ $1 == "stop" ];then
    cd ~/.gofree
    pkill `cat p.txt | xargs` > /dev/null
    # unset http_proxy
    # unset https_proxy
    # unset ALL_PROXY

    rm -rf .json `cat p.txt | xargs` *.log log.txt p.txt
    rm -rf fhbfcgdx* && echo "stop succes"
    cd - > /dev/null
    fi
    ```

    比如我想要克隆仓库 或者 安装软件的时候,我就
    naive start
    pc git clone http://xxxxxx .
    pc conda install xxxx
    pc curl https://xxx
    naive stop
    uCharles
    uCharles
    Dec 12, 2022
    24
    我比较笨,直接用 fastgithub ,或者直接开梯子
    flyico
    flyico
    Dec 12, 2022
    25
    很奇怪,我这的网络,github 要么连不上,要么速度飞快
    20150517
    20150517
    Dec 12, 2022
    26
    我国内有服务器啊,在腾讯的,我能够用 git clone ,就是速度有点慢
    wdssmq
    wdssmq
    Dec 12, 2022
    27
    @bipy #8

    HOST_IP=$(cat /etc/resolv.conf | grep nameserver | awk '{print $2}')
    cat > ~/.ssh/config <<EOF
    Host github.com
    User git
    ProxyCommand nc -v -x ${HOST_IP}:10810 %h %p
    # ProxyCommand nc -X 5 -x ${HOST_IP}:10810 %h %p
    EOF

    wsl2 内搞不定。
    MrTlyer
    MrTlyer
    Dec 20, 2022
    28
    CF 上搭建 GitHub 代理: https://g.ntnas.top
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   4740 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 73ms · UTC 02:22 · PVG 10:22 · LAX 18:22 · JFK 21:22
    ♥ Do have faith in what you're doing.