δΈζ | English
SSH Relay Guard is an Antigravity extension that manages SSH reverse tunnels and transparently routes remote traffic through your local proxy β bypassing network restrictions and DNS pollution on remote servers.
GitHub: double12gzh/ssh-relay-guard
- π SSH Reverse Tunnel β Automatically configures
~/.ssh/config.srgwith per-hostRemoteForwardandControlMasterblocks. - π‘οΈ Language Server Proxy β Wraps the remote language server binary with
mgraftcp-fakednsfor transparent process-level proxy, bypassing DNS pollution. - π Status Dashboard β Real-time panel showing local/remote proxy health, SSH tunnel state, and connection metrics.
- π Health Check β Full diagnostic suite: local proxy, SSH config, remote port forwarding, binary check, external connectivity, and DNS pollution detection.
- π Traffic Monitor β Live connection count and session statistics on the remote side.
- π Bilingual UI β Chinese and English support.
- On the local machine: the extension writes an SSH config block in
~/.ssh/config.srgthat forwards the remote proxy port back to your local proxy. - On the remote machine: the extension installs a wrapper script around the language server binary that forces it through
mgraftcp-fakedns.
π Manual Reproduction Guide β Explains the minimal commands needed to manually replicate what the extension does, with a full data flow diagram.
SRG uses a local + remote dual deployment model, with each side handling different tasks:
- A running local proxy (Clash / V2Ray / etc.) with working Antigravity AI features confirmed locally
- A remote Linux x86_64 server accessible via SSH
- Passwordless SSH authentication β The SSH tunnel daemon runs in the background with
BatchMode=yesand cannot prompt for passwords or passphrases. You must use one of:- An SSH key without a passphrase
- An SSH key with passphrase pre-loaded into ssh-agent (
ssh-add ~/.ssh/id_ed25519) - macOS Keychain integration (
AddKeysToAgent yes+UseKeychain yesin~/.ssh/config)
Local side
- Search for and install SSH Relay Guard in the Antigravity extension marketplace
- Open settings and set
localProxyPortto your local proxy port (default7890) - Run command
SSH Relay Guard: Add Host Forwardingand enter the remote hostname (as in~/.ssh/config)
Remote side
- Connect to your remote server via SSH through Antigravity
- Install SSH Relay Guard again in the remote extension list
- Restart the remote window when prompted (may require multiple restarts)
Verify
- Open the SRG Dashboard β Run "Health Check" β All items showing β means setup is complete
| Setting | Default | Description |
|---|---|---|
ssh-relay-guard.enableLocalForwarding |
true |
Enable SSH reverse tunnel management |
ssh-relay-guard.localProxyPort |
7890 |
Local proxy port (e.g., Clash, V2Ray) |
ssh-relay-guard.remoteProxyPort |
7890 |
Default remote proxy port. If occupied, the tunnel auto-negotiates to the next available port |
ssh-relay-guard.remoteProxyHost |
127.0.0.1 |
Remote proxy host address |
ssh-relay-guard.proxyType |
http |
Proxy protocol: http or socks5 |
ssh-relay-guard.showStatusOnStartup |
true |
Show status notification on connection |
| Command | Description |
|---|---|
SSH Relay Guard: Show Dashboard |
Open the status dashboard |
SSH Relay Guard: Add Host Forwarding |
Configure SSH tunnel for a host |
SSH Relay Guard: Remove Host Forwarding |
Remove SSH tunnel for a host |
SSH Relay Guard: Run Health Check |
Full diagnostic report |
SSH Relay Guard: Setup Remote Environment |
Install language server wrapper |
SSH Relay Guard: Rollback Remote Environment |
Restore original language server |
SSH Relay Guard: Show Traffic Monitor |
View connection statistics |
srg-cli is NOT bundled with the extension. It is a standalone command-line tool for users who don't use Antigravity or need to manage multiple remote hosts from the terminal.
If you only use Antigravity, you do NOT need srg-cli β the extension handles everything automatically via the
Setup Remote Environmentcommand.
# Clone the repository
git clone https://github.com/double12gzh/ssh-relay-guard.git
cd ssh-relay-guard/srg-cli
# (Optional) Build mgraftcp-fakedns pre-compiled binaries
# Requires Linux + go, make, gcc
bash build-bin.sh
# Add srg to PATH
export PATH="$PWD:$PATH"
# Or create a symlink
ln -s "$PWD/srg" /usr/local/bin/srg# One-time setup for a remote host
srg setup my-server
# Check status
srg status my-server
# Diagnose issues (full local + remote diagnostics)
srg doctor my-server
# List configured hosts
srg list
# Remove all configuration
srg teardown my-server| Feature | Antigravity Extension | srg-cli |
|---|---|---|
| SSH tunnel config | β Automatic | β
srg setup |
| Language Server proxy | β Automatic | β
srg setup |
| Remote tool deployment (srg-on/off/...) | β Automatic (embedded scripts) | β
srg setup (standalone scripts) |
| Status dashboard | β WebView panel | β
srg status / srg tui |
| Health diagnostics | β In-panel | β
srg doctor |
| Requires Antigravity | β Yes | β No |
| Multi-host management | β
srg list centralized |
| Command | Description |
|---|---|
srg-on |
Enable proxy for current shell |
srg-off |
Disable proxy for current shell |
srg-shell |
Open a new shell with proxy enabled |
srg-proxy <cmd> |
Run a single command through transparent proxy |
srg-status |
Show current proxy status |
Note: When using these commands from an external SSH terminal (not VS Code's integrated terminal), the proxy port is auto-detected by probing the configured port and nearby ports (+1 to +10) using a
curlproxy handshake. If the SSH tunnel port was auto-negotiated to a different port due to conflicts, the CLI tools will find it automatically. If no reachable proxy port is found, a warning is shown.
SRG uses a dedicated ~/.ssh/config.srg file included from the main SSH config:
# SSH Relay Guard β Tunnel & Proxy Config
# --- SRG:my-server ---
Host my-server
RemoteForward 7890 127.0.0.1:7890
ExitOnForwardFailure no
ControlMaster auto
ControlPath ~/.ssh/sockets/%r@%h-%p
ControlPersist 4h
# --- SRG:my-server END ---
When uninstalling, the extension automatically cleans up local SSH configuration (~/.ssh/config.srg and the Include line in ~/.ssh/config). No manual rollback is needed.
Remote artifacts (LS wrapper, ~/bin/srg-* tools) are safe to leave β the LS wrapper has a built-in fallback that runs the original binary if mgraftcp is missing. To fully clean up the remote server, run SSH Relay Guard: Rollback Remote Environment before uninstalling.
git clone https://github.com/double12gzh/ssh-relay-guard.git
cd ssh-relay-guard
npm installTo test and debug the extension locally:
- Open this project in VS Code / Antigravity.
- Press
F5to launch a new "Extension Development Host" window. - Make changes to the source code.
- Run
Developer: Reload Window(Cmd+RorCtrl+R) in the debug host to immediately apply changes.
This project integrates ESLint (with strict TypeScript rules) and Prettier for formatting. A husky pre-commit hook ensures code quality before every commit.
# Format codebase (Prettier)
npm run format
# Run linting and autofix (ESLint)
npm run lint -- --fix
# Run all unit tests (100% coverage)
npm run test# Compile and actively watch for changes
npm run watch
# Package the extension into a .vsix file (for manual installation)
npx -y @vscode/vsce package --no-dependenciesPush a version tag to trigger CI/CD, which automatically publishes to both marketplaces:
git tag v0.1.0
git push origin --tags# Publish to VS Code Marketplace
# Requires a Personal Access Token from https://dev.azure.com β User Settings β Personal access tokens
# Scopes: Marketplace β Manage
npx -y @vscode/vsce publish -p <YOUR_VSCE_PAT>
# Publish to Open VSX Registry
# Requires an Access Token from https://open-vsx.org β User Settings β Access Tokens
npx -y ovsx publish -p <YOUR_OVSX_PAT>MIT Β© double12gzh

