6

Configure Git to use a proxy (https or SSH+GIT)

 2 years ago
source link: https://gist.github.com/ozbillwang/005bd1dfc597a2f3a00148834ad3e551
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

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

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.

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
proxyUsername:proxyPassword

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 ~/.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


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK