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

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

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

    仅仅通过本地改 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 条回复    2023-09-04 13:09:11 +08:00
    devliu1
        1
    devliu1  
       237 天前
    搜索 ssh proxycommand
    coolcoffee
        2
    coolcoffee  
       237 天前
    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  
       237 天前
    楼主可以在远程 server 用 gost 启动一个 socks5 server ,然后 ssh forward 到本地。但是 ssh forward 容易断,并且流量大了也容易限流。
    hxy100
        4
    hxy100  
       237 天前
    楼上两位正解
    yagamil
        6
    yagamil  
    OP
       236 天前
    @coolcoffee @devliu1 ,谢谢,用上了。给大佬点赞。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2840 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 12:24 · PVG 20:24 · LAX 05:24 · JFK 08:24
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.