Configuration October 31, 2026

Clash Proxy Setup for Developers: Git, SSH, and Homebrew

Set up Clash for the tools developers use every day. Learn how to route Git, SSH, and Homebrew traffic, check terminal proxy behavior, and troubleshoot common connection and download failures.

Docker Proxy GitHub Acceleration Advanced Config YAML

1. Scope: route developer traffic without proxying everything

This guide is for developers who use a Mihomo-compatible Clash client—such as Clash Verge Rev—and need dependable access to Git remotes, SSH hosts, and Homebrew downloads. The goal is not to make every application use the same route. It is to understand which part of the toolchain makes each connection, then choose a suitable path for that traffic while keeping private repositories, internal services, and ordinary local traffic on the routes your network policy requires.

A browser test is not enough. Your browser may use the system proxy, while a terminal process uses its own networking library and ignores that setting. Git can use proxy configuration of its own; an SSH remote normally opens a raw TCP connection; and Homebrew may invoke Git, curl, or other helpers while resolving and downloading a formula. As a result, “the website opens” does not prove that git fetch, an SSH clone, or brew install will work.

Clash can direct connections using rules in the active Mihomo profile, and many clients also provide local HTTP and SOCKS ports. The actual port numbers, rule names, and mode depend on your configuration. Examples below use 7890 for a mixed HTTP/SOCKS port and 7891 for a SOCKS port, but check the client’s port settings before copying commands. A local port is useful only while the Clash core is running and listening on that address.

There are two complementary ways to route developer tools. A rule-based setup sends matching destinations through a proxy group even when a program does not understand proxy environment variables. An application-level setup explicitly points Git, SSH, or a shell tool at a local Clash listener. The first gives centralized control; the second helps when an application bypasses system proxy settings or when you need to test one command in isolation. Many developers use both, but should avoid configuring two different proxies without knowing which one wins.

Before changing anything, confirm that your use of a relay complies with employer policy, repository terms, and any applicable data-handling requirements. A proxy changes the network path; it does not make credentials, source code, or private package metadata safe to send through an untrusted operator. Prefer a trusted route, keep authentication tokens out of shell history, and do not publish a profile containing subscription URLs or credentials.

2. Prepare Clash rules and verify the local listener

Start with the active profile, not a YAML file you think the client is using. In Clash Verge Rev or another Mihomo client, check which profile is selected, whether the core is running, and which proxy group will handle developer traffic. A rule pointing to a nonexistent group may be rejected or behave differently than intended. If your profile is managed by a subscription, use the client’s supported overrides or rule providers rather than editing a generated file that will be replaced on its next update.

For a focused setup, put exceptions for trusted internal services before broad rules that send traffic through a proxy. Then add the public code-hosting destinations you actually need. For example, GitHub operations can involve the main site, API, release downloads, and Git LFS object storage; a rule for only github.com may not cover every transfer. The precise hostnames depend on the operation and current service infrastructure, so use connection logs to discover what is missing instead of adding broad wildcards without review.

rules:
  - DOMAIN-SUFFIX,corp.example,DIRECT
  - DOMAIN-SUFFIX,github.com,Developer
  - DOMAIN-SUFFIX,githubusercontent.com,Developer
  - DOMAIN-SUFFIX,githubassets.com,Developer
  - DOMAIN-SUFFIX,githubusercontent.com,Developer
  - MATCH,Default

This is an illustrative fragment, not a complete profile: Developer and Default must match proxy-group names that exist in your configuration, and ordering matters. The duplicate-looking scope of related service domains is intentional to consider, but do not paste redundant rules as a substitute for observing traffic. Remove duplicate entries when adapting the example, and add only domains supported by logs or the service documentation. A final catch-all rule should reflect your own policy rather than blindly copying MATCH behavior.

After applying a change, open the client’s connection panel and generate a fresh request. Filter the log by the destination hostname and verify both the matched rule and selected outbound. A browser request can help check DNS and domain rules, but test the real command too: Git over HTTPS, SSH, and a Homebrew bottle download do not necessarily use the same hostnames or proxy mechanism. If the log shows an IP address rather than a domain, review DNS mode and rule behavior before adding an overly broad IP rule.

To check whether a local listener is available, inspect the client settings and use a simple request from the same shell that will run your tools. For an HTTP listener, a request to a known HTTPS site can be made with curl’s -x option. A successful response confirms that the command reached a proxy; it does not prove that every later request, redirect, or download host follows the same route. If the connection is refused, verify the port, bind address, and whether the client is running before debugging Git itself.

curl -I -x http://127.0.0.1:7890 https://github.com
env | grep -i proxy

Treat the client’s connection log as the source of truth for routing, and the tool’s own verbose output as the source of truth for how that tool is attempting to connect. Keeping both views open makes it easier to distinguish a rejected local connection from a remote timeout, authentication failure, or DNS problem.

3. Configure Git over HTTPS without leaking credentials

For HTTPS remotes, Git can use a proxy independently of the system proxy. A one-command test avoids leaving a setting behind and is useful when comparing a normal fetch with a proxied one:

git -c http.proxy=http://127.0.0.1:7890 ls-remote https://github.com/OWNER/REPOSITORY.git

If the test works and you want Git to use the local listener by default, set a global value only if that is appropriate for all of your repositories:

git config --global http.proxy http://127.0.0.1:7890
git config --global --get http.proxy

A global proxy can surprise you later when you are on a network where the local Clash listener is unavailable, or when a corporate repository must remain on a separate route. You can instead configure a proxy for a URL scope, use a repository-local setting, or leave Git unconfigured and rely on Clash’s domain rules. To remove the global value, use git config --global --unset http.proxy. Check repository configuration as well: a local value can override a global setting, and environment variables can affect the process too.

For temporary shell-level routing, set standard proxy variables only for the current terminal session. Many command-line clients recognize these variables, but support varies by runtime and version; Git’s explicit configuration is easier to inspect when troubleshooting. Use the exact scheme that matches the listener. An HTTP proxy listener can usually handle HTTPS destinations through the HTTP CONNECT method, while a SOCKS listener requires a SOCKS URL such as socks5h://. The trailing h requests proxy-side hostname resolution in clients that support it, which can matter when local DNS results differ from the proxy’s view.

export HTTP_PROXY=http://127.0.0.1:7890
export HTTPS_PROXY=http://127.0.0.1:7890
export http_proxy="$HTTP_PROXY"
export https_proxy="$HTTPS_PROXY"

# Clear the variables when the test is complete.
unset HTTP_PROXY HTTPS_PROXY http_proxy https_proxy

Avoid putting usernames, passwords, or access tokens directly into a proxy URL stored in shell history or a shared dotfile. Git credentials for the remote are separate from the proxy itself: use your operating system’s credential manager or the host’s recommended authentication method. If a public repository fetch works but a private one returns an authorization error, investigate credentials and repository permissions before changing routing rules.

If Git LFS or release downloads fail while ordinary clone and fetch operations succeed, inspect the failed destination in Clash’s log and Git’s verbose output. LFS objects and release files may use a different hostname from the repository page. Add a narrowly scoped rule for the observed service host if necessary, then repeat the same failing operation. Do not assume that increasing timeouts will fix a request that is being sent DIRECT when it needs a proxy, or sent through an unreachable proxy when it should be DIRECT.

4. Route SSH remotes deliberately

SSH is not HTTP. A Git remote such as [email protected]:OWNER/REPOSITORY.git usually opens a TCP connection to port 22 and does not automatically read HTTPS_PROXY. That is why setting proxy variables can fix a GitHub HTTPS remote while an SSH clone still times out. If your Clash profile already routes the SSH destination through a suitable outbound, a domain rule may be enough; otherwise, SSH needs a local proxy command or a supported alternate endpoint.

First test the direct SSH path with verbose output. This reveals the host and port SSH is trying to reach, as well as whether the failure occurs before key authentication. If your rules are intended to catch this connection, look for the corresponding connection in Clash’s log while the command runs. A timeout before the server presents its host key points toward reachability or routing; a public-key rejection usually means the network connection succeeded and the authentication setup needs attention.

ssh -vT [email protected]

One option is to use a local SOCKS listener through an SSH ProxyCommand. The exact command depends on the netcat implementation installed on your system. Some builds support the -X 5 -x SOCKS options shown below; others do not. Test the command with a single SSH invocation before adding it to your configuration. If your system netcat lacks these flags, install or select a compatible proxy helper, or use a supported HTTP CONNECT helper with the matching Clash listener.

ssh -o 'ProxyCommand=nc -X 5 -x 127.0.0.1:7891 %h %p' -T [email protected]

For a repeatable setup, add a host-specific entry to ~/.ssh/config rather than applying a proxy command to every SSH connection. Keep the rule limited to the provider that needs it; internal hosts may require a corporate gateway, a private network, or direct access.

Host github.com
    HostName github.com
    User git
    ProxyCommand nc -X 5 -x 127.0.0.1:7891 %h %p

GitHub also documents an SSH-over-port-443 endpoint for networks that block outbound port 22. That is a separate choice from using a SOCKS proxy: it changes the SSH destination and port, and it may not be appropriate for every Git provider. If you use it, configure a host alias so ordinary SSH destinations are unaffected, and verify the provider’s current instructions before relying on the endpoint. Do not redirect all SSH connections to port 443 just because one service supports it.

Once SSH connects, verify the server’s host key through the provider’s trusted documentation or your organization’s process. A proxy changes the route but does not replace SSH’s host verification. Do not “fix” a first-connection warning by disabling strict host-key checking globally. If the connection still fails, compare the SSH hostname, port, proxy helper output, Clash log entry, and the result of an HTTPS remote; those checks narrow the problem to the route or the SSH-specific configuration.

5. Make Homebrew downloads predictable and diagnose failures

Homebrew is a workflow rather than a single network client. It may consult formula metadata, fetch source archives or prebuilt bottles, and run Git or curl operations along the way. A successful brew update therefore does not guarantee that a later bottle download will work. Conversely, a failed installation does not automatically mean Homebrew itself is misconfigured; a particular download host may be unreachable or routed differently.

Begin by checking the process environment and the active Clash rules. If the command-line tools in your shell honor proxy variables, you can test Homebrew in that session without changing your permanent shell startup files:

export HTTP_PROXY=http://127.0.0.1:7890
export HTTPS_PROXY=http://127.0.0.1:7890
export http_proxy="$HTTP_PROXY"
export https_proxy="$HTTPS_PROXY"

brew update
brew install PACKAGE_NAME

Some tools use lowercase variables, some prefer uppercase, and some rely on their own configuration. Supplying both cases during a controlled test can help reveal a difference, but do not leave duplicated settings in multiple startup files indefinitely. If Homebrew runs from a GUI-launched terminal or an IDE, that process may inherit a different environment from your interactive shell. Restart the terminal or IDE after changing environment settings, then confirm what the actual process sees.

When installation fails, capture the exact URL or hostname shown by Homebrew’s output and search for it in Clash’s connection log. If the request never appears, the tool may be using a different network path, a proxy variable may be missing, or DNS may have failed before a connection was created. If it appears as DIRECT, check rule ordering and the matched rule. If it selects the intended proxy but times out, test the proxy group with another request and consider whether the selected node can reach that destination. If the request succeeds but Homebrew reports a checksum or extraction error, investigate the downloaded file and formula rather than changing proxy rules.

A concise diagnostic sequence prevents random edits. First, repeat the failing command once and note its timestamp, hostname, and error. Second, inspect the relevant Clash connection and record the rule and outbound. Third, test the same URL with curl through the intended listener, if the URL is safe to request directly. Fourth, compare the result without explicit proxy options to determine whether environment configuration changes the path. Finally, remove temporary overrides and retest using the steady-state configuration you plan to keep. This makes it possible to tell whether the fix came from a routing rule, an application setting, a node change, or a temporary shell variable.

Common symptoms point to different layers. “Connection refused” to 127.0.0.1 usually means the local listener is not running at that address and port. A DNS lookup failure suggests checking the resolver and DNS mode. A TLS or certificate error may involve interception, a system clock problem, or a corporate certificate policy; do not disable certificate validation as a shortcut. A long pause followed by a timeout can indicate an unreachable outbound, a blocked destination port, or a proxy setting that the program does not understand. A fast HTTP 403 or authentication error often means the network path worked and the remote service rejected the request.

For team machines, document the intended behavior rather than merely sharing a list of ports: which public hosts should use the developer proxy, which private hosts must remain on an approved path, where the Clash listener is configured, and how to confirm a rule match. Keep examples free of personal subscription links and secrets. Revisit the host list when a provider changes its download infrastructure, and prefer observed connection logs over a large, permanent wildcard set that silently routes unrelated traffic.

Some all-in-one VPN toggles are convenient for a single browser session but offer little visibility into why Git, SSH, and Homebrew take different paths. Clash’s useful advantage here is more specific: rule-based routing can keep internal repositories separate, while local HTTP or SOCKS listeners let you test individual terminal tools and inspect their connections. If you want that level of control across your developer workflow, choose the client that fits your platform and verify its listener settings before you start:

Download Clash

Ready to get started?

Choose a Clash client, check its local proxy ports, and apply the routing approach that fits your developer tools.