zoukankan      html  css  js  c++  java
  • github代理

    This tuturial will explain how to use git through a proxy, for example if you are behind a firewall or on a private network.

    The examples are valid for connections inside the .cms network at Point 5, but it should be simple to adapt them to other configurations.

    What kind of proxy

    The most common are an HTTP proxy, and a SOCKS5 proxy - for example, one opened with the ssh -D command, documented in ssh(1).

    How to open a SOCKS proxy through an SSH tunnel

    The ssh command distributed with most Unix-like systems can open a SOCKS proxy on the local machine and forward all connections through the ssh tunnel.

    For example

    ssh -f -N -D 1080 cmsusr.cms
    

    will connect to the host cmsusr.cms, open a SOCKS proxy on the local host on port 1080 (-D 1080), and put the process in background after a successful connection (-f -N).

    How to connect to a git repository using the SSH protocol

    If the remote has a format like

    git@github.com:cms-sw/cmssw.git
    ssh://git@github.com/cms-sw/cmssw.git
    

    then you are connecting to the git server using the SSH protocol.

    In this case, git relis on ssh to handle the connection; in order to connect through a SOCKS proxy you have to configure ssh itself, setting the ProxyCommand option in your ~/.ssh/config file:

    Host github.com
        User                    git
        ProxyCommand            nc -x localhost:1080 %h %p
    

    OR On CentOS7 you can

    Host github.com
        User                    git
        ProxyCommand            ssh cmsusr nc %h %p
    

    For more information, see ssh_config(5).

    How to connect to a git repository using the HTTP or HTTPS protocols

    If the remote has a format like

    http://github.com/cms-sw/cmssw.git
    https://github.com/cms-sw/cmssw.git
    

    then you are connecting to the git server using the HTTP or HTTPS protocols. In the old days, this used to be a dumb protocol, but since git 1.6.6 it uses a smart protocol similar to that used by SSH or GIT.

    In this case git uses libcurl to handle the connection; the version of git bundled with CMSSW supports different kinds of proxies: SOCKS4, SOCKS4a, SOCKS5, and HTTP/HTTPS. In order to connect through any proxy supported by libcurl, you can set the http.proxy option:

    git config --global http.proxy socks5://localhost:1080
    

    For more information, see the --proxy option in curl(1) and the http.proxy entry in git-config(1).

    How to connect to a git repository using the GIT protocol

    If the remote has a format like

    git://github.com/cms-sw/cmssw.git
    

    then you are connecting to the git server using the GIT protocol.

    In this case, it is possible to use a helper command to connect through any kind of proxy. A simple script is included with CMSSW, to connect through a SOCKS5 proxy: git-proxy. You can configure git to use it with

    git config --global core.gitproxy "git-proxy"
    git config --global socks.proxy "localhost:1080"
    

    For more information, see git-proxy --help.

    link

  • 相关阅读:
    Educational Codeforces Round 15 C. Cellular Network(二分)
    HDU 1044 Collect More Jewels(BFS+DFS)
    NBOJv2 Problem 1009 蛤玮的魔法(二分)
    HDU 1016 Prime Ring Problem(经典DFS+回溯)
    HDU 2181 哈密顿绕行世界问题(经典DFS+回溯)
    OpenCV学习笔记——滑动条开关
    廖雪峰Java15JDBC编程-3JDBC接口-3JDBC更新
    廖雪峰Java15JDBC编程-3JDBC接口-1JDBC简介
    廖雪峰Java15JDBC编程-2SQL入门-2insert/select/update/delete
    廖雪峰Java15JDBC编程-2SQL入门-1SQL介绍
  • 原文地址:https://www.cnblogs.com/ijpq/p/15428294.html
Copyright © 2011-2022 走看看