Hướng Dẫn Sử Dụng
Comprehensive Step-by-Step Guide to Configuring Proxy for Git and SSH Client

Table of contents
The Importance of Configuring Proxy for Git and SSH
In enterprise software development environments, engineers frequently work behind strict firewall systems or internal networks with restricted outbound Internet connectivity. This directly disrupts basic operations such as cloning source code repositories, pushing code, or updating working branches from popular hosting services.
Mastering the technique of configuring a proxy for Git not only completely resolves network disruption issues but also helps route traffic through stable intermediary servers, optimizing developers' daily workflows.
Distinguishing Git's Two Connection Protocols: HTTPS and SSH
Git supports two main transport protocols for interacting with remote servers: HTTPS and SSH. Each protocol uses a different security mechanism and port, requiring a distinct proxy configuration method.
- HTTPS Protocol: Uses standard ports and is easily compatible with common web proxy servers via Git's built-in commands.
- SSH Protocol: Uses authentication keys and its own encrypted channel, requiring direct configuration interventions into the SSH Client background process on the operating system.
Configuring HTTP and HTTPS Proxy for Git
1. Setting Global or Per-Project Proxy
To route Git commands using URLs starting with HTTP or HTTPS through an intermediary server, developers use the git config http proxy command. You can choose to apply this globally across the system or only within the current project directory.
Set global scope using the following command lines:
git config --global http.proxy http://proxy-address:port
git config --global https.proxy https://proxy-address:port
If the intermediary server requires username and password authentication, the URL format is written in full including login credentials:
git config --global http.proxy http://username:password@proxy-address:port
If you only want to apply this within a single repository, simply omit the --global parameter when executing the command inside the project directory.
2. Using SOCKS5 Protocol for Git HTTP Connections
Besides traditional HTTP Proxy, the socks5 proxy git protocol is highly favored due to its flexible data transmission capabilities. You can configure this protocol directly through Git:
git config --global http.proxy socks5://proxy-address:port
git config --global https.proxy socks5://proxy-address:port
3. Removing Proxy Configuration When No Longer Needed
When leaving the office network environment or switching to an open network, you should remove these configurations to avoid network bottleneck errors:
git config --global --unset http.proxy
git config --global --unset https.proxy
Configuring SSH Proxy for Git
The SSH protocol provides security and convenience by eliminating the need to re-enter credentials for every interaction. However, SSH traffic is often restricted on internal network ports. Setting up a git ssh proxy is the standardized solution to handle this scenario.
1. Configuring the SSH config File
The SSH Client looks for connection directives in a text file located in the user's home directory. The default path for this file is typically ~/.ssh/config on Linux/macOS or C:\Users\Username\.ssh\config on Windows operating systems.
If the file does not exist yet, create a new plain text file without any file extension.
2. Routing via HTTP Proxy Using netcat or connect-proxy
On Linux and macOS operating systems, the nc (netcat) tool is usually built-in. To forward SSH packets through an HTTP proxy server, add the following configuration block to the file:
Host github.com
User git
ProxyCommand nc -X connect -x proxy-address:port %h %p
For Windows users using Git Bash, the built-in connect tool performs an equivalent role:
Host github.com
User git
ProxyCommand connect -H proxy-address:port %h %p
3. Routing SSH via SOCKS5 Proxy
When the internal network supports a SOCKS5 server, the routing code in the SSH configuration file is configured as follows:
On Linux and macOS platforms:
Host github.com
User git
ProxyCommand nc -X 5 -x proxy-address:port %h %p
On Windows platforms with Git Bash:
Host github.com
User git
ProxyCommand connect -S proxy-address:port %h %p
Testing and Troubleshooting Connections
1. Verifying HTTPS Protocol Connections
The simplest way to verify the proxy configuration for HTTPS links is to test cloning an open-source remote repository. If the clone process proceeds smoothly without connection refused errors, the system is operating normally.
2. Testing SSH Channel Connectivity
The dedicated SSH connection test command helps display detailed network handshake steps without modifying the repository state:
ssh -Tv [email protected]
The -v (verbose) flag enables detailed logging mode, clearly displaying the connection path via the ProxyCommand process. If a welcome message indicating successful authentication appears, the entire SSH Proxy setup is complete.
3. Notes on SSL Certificate Issues in Enterprise Networks
Some internal network monitoring systems use custom security inspection certificates, leading to SSL authentication warning errors when executing Git commands. In this case, the safe solution is to configure the path to the approved internal certificate bundle:
git config --global http.sslCAInfo /path/to/certificate.crt
Avoid completely disabling SSL verification, as this can introduce undesirable security risks to your workstation.
Conclusion
Setting up intermediary channels for Git and SSH is a practical skill that helps software engineers maintain a continuous, stable workflow in all complex enterprise network conditions. Depending on whether HTTPS or SSH is used, applying the correct routing method will ensure fast and secure source code deployment.
Related articles
Ready for real proxies, not just the guide?
Buy Residential, ISP, Datacenter, or Mobile proxies — live in minutes.
View products