Git proxy settings and access GitHub

Source: Internet
Author: User
Tags ssh config ssh config file opentsdb
Due to the strict restrictions on the network environment currently in work, it can be said that it has recently paid a lot of twists and turns to access GitHub through proxy, and has accumulated some relevant experience. I think it is necessary to forget it. In line with the purpose of "never re-invent the wheel", this article will not repeat every detail of the GitHub proxy settings, the article will provide a ready-made reference article, what we need to do here is to explain and supplement some important questions. I believe it will be helpful to friends who encounter the same problems. Source of the original article: http://blog.csdn.net/bluishglc/article/details/37807501 prohibit any form of reprint, otherwise it will entrust csdn official maintenance rights!

1. Don't worry about it. Please block NTLM verification first!

First, if your network proxy uses NTLM authentication and does not make any unnecessary "struggles", install cntlm first to create a common HTTP proxy without authentication, because the current version of git does not support NTLM Authentication Proxy and does not block NTLM verification with cntlm, any subsequent work will be meaningless. For installation and configuration of cntlm, see: http://blog.csdn.net/bluishglc/article/details/37600773

2. The GIT proxy configuration starts.

For details about git proxy configuration, refer to: http://jixiuf.github.io/git/git-proxy-on-windows.html here to briefly explain the SSH config file mentioned in this Article, this file is mainly to save some frequently accessed connection configurations of the target host, similar to the session saved in putty. The Config File structure is a set of configuration items starting with the host. The configuration items after the host item and before the next host are all configured for this host! In addition, the connect mentioned in the config file in this article is a proxy forwarding tool. It is unlikely to design how to configure the proxy for a simple command line tool, or, for example, ssh, delegate the proxy configuration to a third-party tool to ensure a single function of the program itself, which is the role of connect.

3. https ://? Yes! Git ://? No!

Install and configure cntlm. refer to the previous article for configuration. We can check the repository in https: // description on GitHub. If you try to use git: // or address access in [email protected] format, the following error may be reported in some proxy environments:

HTTP/1.1 502 proxy error (the specified Secure Sockets Layer (SSL) port is not allowed. forefront TMG is not configured to allow SSL requests from this port. most Web browsers use port 443 for SSL requests .)

The cause of this problem is GIT: // port 9418 and port 22 of the SSH-based [email protected] address are blocked by the firewall in your network environment (especially the proxy server. This is extremely common. Most proxy environments shield ports except 80 (HTTP) and 443 (https) based on security considerations. Does this mean that we cannot use git: // or [email protected] addresses in this network environment? Continue with the following.


4. Fortunately, you have SSH over the HTTPS port.


Although the HTTPS protocol push code can be used on GitHub (using the username and password on GitHub), it is generally safer to use SSH to detect and submit code, it is more suitable for team development. How can we solve the problems mentioned above? In this regard, GitHub uses ssh.github.com to solve this problem by specifying the SSH connection port as 443 used by HTTPS, in this way, we can use SSH to access GitHub through port 443 allowed by most proxy servers. This is also configured in the config file mentioned in the previous reference article, this is the part where the host is ssh.github.com. For instructions and configurations of this Part, the GitHub official help documentation also describes https://help.github.com/articles/using-ssh-over-the-https-port. Here I just want to explain how to verify that the configuration has been successful. Obviously, if we can log on to the target host through SSH, the configuration is correct:

Method 1: As mentioned above, it writes the configuration parameters of ssh.github.com into the SSH config file, which can be used in the command line tool.

Ssh-T-P 443 [email protected]

Check whether the configuration of the config file is correct. After Successful Logon, the following message is displayed:

Method 2: If we cannot determine the correctness of these parameters before configuring them, we can first specify these parameters through the command line, after the verification is passed, these parameters are written to the config file. The command should be written as follows:

Ssh-O proxycommand = "/path/to/connect-H proxy host: port % H % P "-I"/path/to/Your/github_private_key "-T-P 443 [email protected]

After successful logon, the following message is displayed:


Method 3: Putty can also be used for verification in a completely independent and convenient way, that is, to create a session in putty, the target host is ssh.github.com, port 443, log on to username 443 and specify your GitHub private key. (Note: the private key format used by Putty is different from that used by OpenSSH, if you do not save the private key in the putty format, you need to generate or convert it using the keygen tool of putty), set the proxy host and port, and connect to the port. If the prompt appears, it also indicates that the configuration is correct!


The last note is that after the above configuration verification is successful, we must remember to modify the host name when checking out the project from GitHub and change [email protected] to [email protected]. SSH.Github.com to check out the opentsdb project as an example.

Git clone [email protected]: opentsdb/opentsdb. Git

Changed:

Git clone [email protected]: opentsdb/opentsdb. Git


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.