• 请不要在回答技术问题时复制粘贴 AI 生成的内容
yagamil
V2EX  ›  程序员

如何在本地配置 git,顺畅拉取提交代码?有台海外服务器的情况下

  •  
  •   yagamil · Sep 3, 2023 · 1318 views
    This topic created in 1006 days ago, the information mentioned may be changed or developed.

    仅仅通过本地改 hosts, 或者切换 443 ssh.github.com, 很多时候已经无能为力了。

    有什么好的简便的方法 使用海外主机作为跳板机,端口转发之类的技术, 让本地提交 github 代码更加顺畅?

    已经可以通过 ssh 端口转发,让浏览器走海外服务器出去。

    比如:

    ssh -N -f -L LOCAL_PORT:REMOTE_HOST:PORT -o TCPKeepAlive=yes

    然后本地走 local 的 LOCAL_POST ,数据就可以从 REMOTE_HOST 出去?

    不过不知道本地的 git 如何配置才行,shell 设置 proxy 不管用。

    6 replies    2023-09-04 13:09:11 +08:00
    devliu1
        1
    devliu1  
       Sep 3, 2023
    搜索 ssh proxycommand
    coolcoffee
        2
    coolcoffee  
       Sep 3, 2023
    vim ~/.ssh/config:

    Host github.com
    IdentityFile ~/.ssh/id_rsa
    ProxyCommand nc -X 5 -x 127.0.0.1:7890 %h %p

    127.0.0.1:7890 是本地的 socks5 proxy 。IdentityFile 和 ProxyCommand 是有缩进的。
    coolcoffee
        3
    coolcoffee  
       Sep 3, 2023
    楼主可以在远程 server 用 gost 启动一个 socks5 server ,然后 ssh forward 到本地。但是 ssh forward 容易断,并且流量大了也容易限流。
    hxy100
        4
    hxy100  
       Sep 3, 2023
    楼上两位正解
    yagamil
        6
    yagamil  
    OP
       Sep 4, 2023
    @coolcoffee @devliu1 ,谢谢,用上了。给大佬点赞。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1290 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 44ms · UTC 17:22 · PVG 01:22 · LAX 10:22 · JFK 13:22
    ♥ Do have faith in what you're doing.