Github.com, as a programmer's code warehouse, we often use. But sometimes we can't link it directly through the Internet, only through proxies.
Here I have a proxy server, at first I thought the terminal set up the proxy environment on the line, it is set to add the following lines in your ~/.BASHRC:
[Python]View Plaincopy
- Export http_proxy="http://proxy-server:3128/"
- Export https_proxy="http://proxy-server:3128/"
- Export ftp_proxy="http://proxy-server:3128/"
Once set, use the following command to start it.
[Python]View Plaincopy
- SOURCE ~/.BASHRC
Then testing the wget is no problem, as follows:
But you can't use Git clone.
[Python]View Plaincopy
- git clone [email protected]:aborn/ulitcs.git
The reasons are known through these two articles: Access github.com and using Git over proxies on Windows via proxy
The preparation process is divided into the following steps:
1. Install the Socat and install it under Ubuntu using the following command
[Python]View Plaincopy
- sudo apt-get install Socat
2. Edit a script file named Git-proxy with the following contents
[Python]View Plaincopy
- #!/bin/sh
- # Use Socat-to-proxy git through an HTTP CONNECT firewall.
- # useful if you is trying to clone git://from inside a company.
- # Requires The proxy allows CONNECT to port 9418.
- #
- # Save This file as Gitproxy somewhere in your path
- # (e.g, ~/bin) and then run
- # chmod +x Git-proxy
- # git config--global core.gitproxy git-proxy
- #
- #
- # Configuration. Common proxy ports is 3128, 8123, 8000.
- _proxy=proxy-server
- _proxyport=3128
- exec socat STDIO proxy:$_proxy:$1:$2,proxyport=$_proxyport
3. Put the git-proxy in a directory, as I put it in/home/lisp/local/bin, and add the directory to the path
[Python]View Plaincopy
- CP git-proxy/home/lisp/local/bin/
Add the directory to path, add the following to ~/.BASHRC, and then Souce ~/.BASHRC
[Python]View Plaincopy
- Export path= $PATH:/home/lisp/local/bin
[Python]View Plaincopy
- SOURCE ~/.BASHRC
4. Modify ~/.gitconfig, add the following lines and agents
[Python]View Plaincopy
- Gitproxy = Git-proxy
The contents of my. gitconfig file are as follows:
[Python]View Plaincopy
- [Push]
- Default = Simple
- [User]
- Name = Aborn
- email = [email protected]
- [Core]
- Editor = Emacs
- Gitproxy = Git-proxy
- [HTTPS]
- Proxy = http://proxy-server:3128
- [HTTP]
- Proxy = http://proxy-server:3128
5. Download the conversion protocol file connect.c, click
Just download the connect.c file and compile
[Python]View Plaincopy
- Gcc-o Connect connect.c
Copy the compiled file connect to/home/lisp/local/bin
6. Modify the ~/.ssh/config to add the following line
[Python]View Plaincopy
- Proxycommand/home/lisp/local/bin/connect-h proxy-server:3128%h%p
The contents of my ~/.ssh/config file are as follows:
[Python]View Plaincopy
- Proxycommand/home/lisp/local/bin/connect-h proxy-server:3128%h%p
- Host github.com
- User [email protected]
- Port 443
- Hostname ssh.github.com
Note that the Connect file directory here is the same as the 5th-step directory.
When the above steps are complete, it will be done as follows:
[Python]View Plaincopy
- git clone [email protected]:aborn/ulitcs.git
[Python]View Plaincopy
- git push
Attention:
1. The above proxy-server based on your proxy, set to replace the IP address or domain name of your proxy server
2. The above connect.c file, the compiled connect file, and the Git-proxy file can also be downloaded from here connect.tar.gz and Git-proxy
3. My operating system is Ubuntu 14.04LTS
Git Gem and other proxy setup issues under Linux