Three protocols currently supported by Git git://、ssh:// 和 http://,其代理配置各不相同:core.gitproxy 用于 git:// 协议,http.proxy 用于 http:// 协议,ssh:// 协议的代理需要配置 ssh 的 ProxyCommand Parameters.
Use SSH tunnel for proxy for all protocols
GIT protocol configuration
Create the /path/to/socks5proxywrapper file and use the https://bitbucket.org/gotoh/connect tool to convert the proxy. Each distribution is generally packaged as proxy-connect or connect-proxy.
You can use yanyaoer's method to set up a proxy for git.
As for the ssh+pac+socks agent you mentioned, it does not conflict with the git agent mentioned by yanyaoer.
The socks proxy is a circuit-level underlying proxy, while the proxy set in git config is application-level.
For example, your pac is set up for github.com to use socks 127.0.0.1:7070; and the git config is set up for github.com to use proxy.server.com as a proxy.
Then at this time, when you perform git operations, all network requests will go to proxy.server.com when they reach the socks layer. Naturally, they will not be affected and will go out directly.
If you clone from bitbucket and use the ssh protocol, you can use all ssh proxy methods
For example, if it is an http proxy or socks proxy, you can use http://bent.latency.net/bent/git/goto... This small program is used as the hostProxyCommand
If there is a relay server you mentioned, you can use nc on the remote host to do itnc做ProxyCommand http://www.undeadly.org/cgi?action=ar...
As for the differentiated traffic you mentioned, you can make different settings in ~/.ssh/config. For example, the configuration I used before
In this way, git clone ssh://git@bitbucket.org/XXXX will automatically call the one defined heregit clone ssh://git@bitbucket.org/XXXX时会自动调用这里定义的ProxyCommand
Based on 1L’s answer, I wrote a smart_switcher, which can automatically identify and set various proxies. Based on http proxy configuration, it is especially suitable for various switching situations where the office has a proxy and there is no proxy at home. However, it is simplified to super simple, just set up your Just the gateway IP and Port.
ReadMe here. . .
A smart proxy switcher wrapper, supports http, https, ftp, rsync, ssh(connect depanded), git(connect depanded) protocols. It can automatically detect your network environment and set proxy for you.
If you usually switch the network environment (maybe home with no-proxy and workplace with proxy), it may help you a lot.
Tested in zsh and bash.
Screenshot
Install
Simply source it in your .zshrc, or any shell script resource file like this:
source /path/to/smart_switcher.sh
and, make sure set your proxy_server/gateway in smart_switcher.sh.
Usage
Normally, it executes antomatically when you log in.
smart_switcher supports cecho, who will bring some colors for you.
connect is required if proxy is supported in ssh and git. You can install it easily in path /usr/bin/connect.
The git protocol connection method uses ssh to communicate with the server. Setting ssh to use the sock5 proxy to connect to the server also solves the git proxy problem.
The best solution is proxychains (https://github.com/haad/proxychains).
The following command runs the program
$ proxychains program
It forces TCP connections initiated by a given program to go through a pre-configured proxy. At least on Linux, it's more versatile than "SOCKS proxy to HTTP proxy". The two complement each other and can cover all scenarios requiring agency.
Take Git as an example. Without proxychains, you must set up a proxy for each protocol (http, git, ssh) according to the requirements of the git documentation. The process is complicated and unstable. With proxychains, you can forget all this!
$ sudo apt-get install proxychains
Open /etc/proxychains.conf and comment out the following line (disable remote DNS resolution. There is a risk of DNS pollution. The following describes how to solve the problem of enable not working.)
proxy_dns
Finally add the following line:
socks5 134.64.206.85 1081
$ proxychains git clone git://github.com/yuzhichang/cppdep
$ sudo proxychains apt-get update
Here 134.64.206.85:1081 is the SOCKS proxy location.
Three protocols currently supported by Git
git://
、ssh://
和http://
,其代理配置各不相同:core.gitproxy
用于git://
协议,http.proxy
用于http://
协议,ssh://
协议的代理需要配置 ssh 的ProxyCommand
Parameters.Use SSH tunnel for proxy for all protocols
GIT protocol configuration
Create the
/path/to/socks5proxywrapper
file and use the https://bitbucket.org/gotoh/connect tool to convert the proxy. Each distribution is generally packaged as proxy-connect or connect-proxy.Configure git
or
SSH protocol configuration
Create
/path/to/soks5proxyssh
fileConfigure git to use this wrapper
Of course it can also be configured directly
~/.ssh/config
的ProxyCommand
HTTP protocol configuration
All protocols use http proxy
Based on the previous part, the
/path/to/socks5proxywrapper
file is changed toHTTP protocol configuration
Enable proxy for domain name
Thegitproxy parameter provides the core.gitproxy part of
* for *
结构,具体看man git-config
.You can set http.proxy or core.gitproxy for this repository
http://www.kernel.org/pub/software/sc...
You can use yanyaoer's method to set up a proxy for git.
As for the ssh+pac+socks agent you mentioned, it does not conflict with the git agent mentioned by yanyaoer.
The socks proxy is a circuit-level underlying proxy, while the proxy set in git config is application-level.
For example, your pac is set up for github.com to use socks 127.0.0.1:7070; and the git config is set up for github.com to use proxy.server.com as a proxy.
Then at this time, when you perform git operations, all network requests will go to proxy.server.com when they reach the socks layer. Naturally, they will not be affected and will go out directly.
tsocks - http://tsocks.sourceforge.net/
$ tsocks git clone git@github.com:xxx/xxx.git
If you clone from bitbucket and use the ssh protocol, you can use all ssh proxy methods
For example, if it is an http proxy or socks proxy, you can use http://bent.latency.net/bent/git/goto... This small program is used as the host
ProxyCommand
If there is a relay server you mentioned, you can use
nc
on the remote host to do itnc
做ProxyCommand
http://www.undeadly.org/cgi?action=ar...As for the differentiated traffic you mentioned, you can make different settings in
~/.ssh/config
. For example, the configuration I used beforeIn this way,
git clone ssh://git@bitbucket.org/XXXX
will automatically call the one defined heregit clone ssh://git@bitbucket.org/XXXX
时会自动调用这里定义的ProxyCommand
github ssh proxy | github ssh protocol proxy configuration
Configure a
proxy-wrapper
scriptAdd executable permissions to it
Configuration
.ssh/config
, set a proxy command for github.comMust use ssh protocol
For the git protocol, please refer to [Using GIT through a SOCKS proxy](http://twopenguins.org/tips/git-throu...).
Reference
Based on 1L’s answer, I wrote a smart_switcher, which can automatically identify and set various proxies. Based on http proxy configuration, it is especially suitable for various switching situations where the office has a proxy and there is no proxy at home. However, it is simplified to super simple, just set up your Just the gateway IP and Port.
ReadMe here. . .
smart_switcher
A auto-detect proxy switcher fot http, https, ftp, rsync, ssh, git protocols.
Overview
A smart proxy switcher wrapper, supports http, https, ftp, rsync, ssh(connect depanded), git(connect depanded) protocols. It can automatically detect your network environment and set proxy for you.
If you usually switch the network environment (maybe home with no-proxy and workplace with proxy), it may help you a lot.
Tested in zsh and bash.
Screenshot
Install
Simply source it in your .zshrc, or any shell script resource file like this:
source /path/to/smart_switcher.sh
and, make sure set your proxy_server/gateway in
smart_switcher.sh
.Usage
Normally, it executes antomatically when you log in.
smart_switcher
supports cecho, who will bring some colors for you.connect is required if proxy is supported in ssh and git. You can install it easily in path
/usr/bin/connect
.The git protocol connection method uses ssh to communicate with the server. Setting ssh to use the sock5 proxy to connect to the server also solves the git proxy problem.
1.
Compile the above code using gcc and save it in the environment variable directory and rename it connect
Enter the .ssh directory and create a new one
File config
File proxy-wrapper
There are many answers above. Assume that the program runs git commands without state or working directory, using
-c
参数可以在运行时重载git配置,包括关键的http.proxy
For example:
The best solution is proxychains (https://github.com/haad/proxychains).
The following command runs the program
$ proxychains program
It forces TCP connections initiated by a given program to go through a pre-configured proxy. At least on Linux, it's more versatile than "SOCKS proxy to HTTP proxy". The two complement each other and can cover all scenarios requiring agency.
Take Git as an example. Without proxychains, you must set up a proxy for each protocol (http, git, ssh) according to the requirements of the git documentation. The process is complicated and unstable. With proxychains, you can forget all this!
$ sudo apt-get install proxychains
Open /etc/proxychains.conf and comment out the following line (disable remote DNS resolution. There is a risk of DNS pollution. The following describes how to solve the problem of enable not working.)
proxy_dns
Finally add the following line:
socks5 134.64.206.85 1081
$ proxychains git clone git://github.com/yuzhichang/cppdep
$ sudo proxychains apt-get update
Here 134.64.206.85:1081 is the SOCKS proxy location.