Skip to content

Instantly share code, notes, and snippets.

@vsramalwan
Forked from ozbillwang/Git_Behind_Proxy.md
Created August 14, 2023 14:10
Show Gist options
  • Save vsramalwan/8461b49f4fb5a9ea4a60bfc46a4d7020 to your computer and use it in GitHub Desktop.
Save vsramalwan/8461b49f4fb5a9ea4a60bfc46a4d7020 to your computer and use it in GitHub Desktop.

Revisions

  1. @ozbillwang ozbillwang revised this gist Jun 29, 2023. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion Git_Behind_Proxy.md
    Original file line number Diff line number Diff line change
    @@ -36,7 +36,8 @@ Host github.com
    ForwardAgent yes
    ProxyCommand /usr/bin/corkscrew <replace_with_your_company_proxy_server> <3128> %h %p
    ```
    #### need write down username and password for your proxy
    #### need write down username and password for your proxy.
    In some company policies, the password need be changed every 90 days, so don't remember to update this configuration file when your proxy password is changed.

    ```
    cat ~/.ssh/myauth
  2. @ozbillwang ozbillwang revised this gist Jun 29, 2023. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion Git_Behind_Proxy.md
    Original file line number Diff line number Diff line change
    @@ -36,7 +36,7 @@ Host github.com
    ForwardAgent yes
    ProxyCommand /usr/bin/corkscrew <replace_with_your_company_proxy_server> <3128> %h %p
    ```
    #### need username and password for your proxy
    #### need write down username and password for your proxy

    ```
    cat ~/.ssh/myauth
  3. @ozbillwang ozbillwang revised this gist Feb 20, 2023. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion Git_Behind_Proxy.md
    Original file line number Diff line number Diff line change
    @@ -26,7 +26,7 @@ When we are behind proxy, I have to set ssh config (`~/.ssh/config`) with `Proxy

    Install `corkscrew` or other proxy tool first.

    #### no need set username and proxy for your proxy
    #### with this way, we don't need provide username and password each time when clone the repository behind proxy

    set ssh config
    ```
  4. @ozbillwang ozbillwang revised this gist Feb 20, 2023. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion Git_Behind_Proxy.md
    Original file line number Diff line number Diff line change
    @@ -21,7 +21,8 @@ git clone [email protected]:kubernetes/kubernetes.git
    ```

    ### Work with ssh config
    So I have to set ssh config (`~/.ssh/config`) with `ProxyCommand` properly, git clone start working with proxy.

    When we are behind proxy, I have to set ssh config (`~/.ssh/config`) with `ProxyCommand` properly, git clone start working with proxy.

    Install `corkscrew` or other proxy tool first.

  5. @ozbillwang ozbillwang revised this gist Feb 20, 2023. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion Git_Behind_Proxy.md
    Original file line number Diff line number Diff line change
    @@ -21,7 +21,7 @@ git clone [email protected]:kubernetes/kubernetes.git
    ```

    ### Work with ssh config
    So I have to set ssh config (`~/ssh/config`) with `ProxyCommand` properly, git clone start working with proxy.
    So I have to set ssh config (`~/.ssh/config`) with `ProxyCommand` properly, git clone start working with proxy.

    Install `corkscrew` or other proxy tool first.

  6. @ozbillwang ozbillwang revised this gist Feb 12, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion Git_Behind_Proxy.md
    Original file line number Diff line number Diff line change
    @@ -39,7 +39,7 @@ Host github.com

    ```
    cat ~/.ssh/myauth
    <username>:<password>
    proxyUsername:proxyPassword
    ```
    set ssh config
    ```
  7. @ozbillwang ozbillwang revised this gist Feb 12, 2020. 1 changed file with 19 additions and 0 deletions.
    19 changes: 19 additions & 0 deletions Git_Behind_Proxy.md
    Original file line number Diff line number Diff line change
    @@ -23,6 +23,25 @@ git clone [email protected]:kubernetes/kubernetes.git
    ### Work with ssh config
    So I have to set ssh config (`~/ssh/config`) with `ProxyCommand` properly, git clone start working with proxy.

    Install `corkscrew` or other proxy tool first.

    #### no need set username and proxy for your proxy

    set ssh config
    ```
    Host github.com
    Hostname github.com
    ServerAliveInterval 55
    ForwardAgent yes
    ProxyCommand /usr/bin/corkscrew <replace_with_your_company_proxy_server> <3128> %h %p
    ```
    #### need username and password for your proxy

    ```
    cat ~/.ssh/myauth
    <username>:<password>
    ```
    set ssh config
    ```
    Host github.com
    Hostname github.com
  8. @ozbillwang ozbillwang created this gist Feb 12, 2020.
    48 changes: 48 additions & 0 deletions Git_Behind_Proxy.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,48 @@
    There are several ways to clone a repository from github. Similar from other providers, such as bitbucket, gitlab, etc.

    https://git-scm.com/book/en/v2/Git-on-the-Server-The-Protocols

    Mostly, we use

    - http
    - ssh

    ### Sample clone commands:
    The clone command with protocol `https`

    ```
    git clone https://github.com/kubernetes/kubernetes.git
    ```

    The clone command with protocol `ssh+git`

    ```
    git clone [email protected]:kubernetes/kubernetes.git
    ```

    ### Work with ssh config
    So I have to set ssh config (`~/ssh/config`) with `ProxyCommand` properly, git clone start working with proxy.

    ```
    Host github.com
    Hostname github.com
    ServerAliveInterval 55
    ForwardAgent yes
    ProxyCommand /usr/bin/corkscrew <replace_with_your_company_proxy_server> <3128> %h %p ~/.ssh/myauth
    ```

    ### Work with http/https

    update ~/.gitconfig

    ```
    [http]
    [http "https://github.com"]
    proxy = http://proxyUsername:[email protected]:port
    sslVerify = false
    ```

    `sslVerify` setting is not necessary.

    ### Notes:
    **If you only need access github by the way of `ssh+git`, you needn't set any proxy in `~/.gitconfig` and run `git config --global http.proxy ...` and similar commands at all**