r/opencodeCLI 1d ago

How I Got Muse Spark Working from Pakistan (SSH Tunnel Method)

Muse Spark blocks Pakistan. I spent three days figuring out how around it. Here's everything I learned, what actually works, and how to set it up yourself.

Muse Spark refuses connections from Pakistani IPs. If you're in Pakistan and trying to use it through OpenCode, AionUI, or any other client, you get blocked. VPNs don't work either. Muse Spark detects VPN traffic and blocks it.

The only thing that worked: routing traffic through an SSH tunnel to a server outside Pakistan. Muse Spark treats SSH tunnel traffic as legitimate. VPN traffic gets flagged.

A post by Kind-Card-6864 showed how to use GitHub Codespaces as a free SSH tunnel. The concept was simple:

  1. Create a Codespace (free Linux VM on GitHub's servers)
  2. SSH into it with port forwarding
  3. Route your API traffic through that SSH connection

GitHub gives you 120 free core-hours per month. That's about 60 hours on a 2-core machine. Enough for casual use.

I followed those instructions and it worked perfectly. Muse Spark saw the Codespace's IP (in India) instead of my Pakistani IP. No more blocks.

What You Need

  • A GitHub account (free)
  • GitHub CLI installed (gh)
  • An SSH key connected to GitHub
  • OpenCode or AionUI installed

Step 1: Install GitHub CLI

winget install GitHub.cli

Step 2: Authenticate

Open a terminal and run:

gh auth login

Pick HTTPS, then GitHub.com, then authenticate via browser. After that, add the Codespaces scope:

gh auth refresh -h github.com -s codespace

Step 3: Generate an SSH Key

ssh-keygen -t ed25519 -C "your_email@example.com"

Copy the public key:

cat ~/.ssh/id_ed25519.pub

Go to GitHub → Settings → SSH and GPG keys → New SSH key. Paste it.

Step 4: Create a Repository and Codespace

Create any repo (even an empty one). Then:

gh cs create --repo yourusername/your-repo

Pick a region close to you (Singapore or India work well).

Step 5: Start the SSH Tunnel

gh cs ssh -- -D 1080

This opens an SSH connection with SOCKS5 proxy on port 1080. Keep this terminal running.

Step 6: Convert SOCKS5 to HTTP

Open another terminal:

pip install pproxy
python -m pproxy -l http://127.0.0.1:8080 -r socks5://127.0.0.1:1080

pproxy is more reliable than the older http-proxy-to-socks package, which drops connections constantly.

Step 7: Use the Proxy

For OpenCode CLI, launch it with proxy env vars:

$env:HTTP_PROXY = "http://127.0.0.1:8080"
$env:HTTPS_PROXY = "http://127.0.0.1:8080"
$env:NO_PROXY = "localhost,127.0.0.1"
opencode

For AionUI, set the same env vars before launching it.

Step 8: Keep the Tunnel Alive

Add this to your SSH config (~/.ssh/config):

Host github-codespace-*
    ServerAliveInterval 30
    ServerAliveCountMax 10
    TCPKeepAlive yes

Without keepalive, the tunnel dies after a few minutes of inactivity.

GitHub Codespaces gives you 60 free hours per month. After that, you pay $0.18/core-hour. If you're running it 24/7, you'll burn through free hours in 2.5 days.

Free and Paid Alternatives

I tried a bunch of options. Here's what each one actually gives you.

Oracle Cloud Free Tier (Best Free Option)

Oracle gives you an always-free ARM VM: 4 cores, 24GB RAM. More than enough for a proxy server.

Pros: Free forever. Full Linux VM. You pick the region (India, Japan, US, etc.)

Cons: Signup often fails. You need a credit card for verification (no charges). Account can get suspended if idle for 30+ days.

Setup: Create an account at cloud.oracle.com. Launch an ARM VM in Mumbai or Tokyo. Install SSH. Set up GOST or tinyproxy.

Google Cloud Free Tier

Google gives you an e2-micro instance (0.25 vCPU, 1GB RAM) for free forever.

Pros: Free forever. Reliable infrastructure.

Cons: Tiny machine (1GB RAM). Free only in US regions (us-west1, us-central1, us-east1). 1GB outbound data per month.

Setup: Similar to Oracle. Launch an e2-micro in us-central1.

AWS Free Tier

Amazon gives you 750 hours/month of t2.micro for 12 months.

Pros: Works reliably. Easy to set up. You pick the region.

Cons: Only free for 12 months. Costs ~$8/month after that. Needs credit card.

Setup: Launch a t2.micro in us-east-1 or ap-southeast-1. Install GOST. Done.

RackNerd ($1/month)

If you want a cheap VPS that runs forever, RackNerd has promotional plans around $1/month.

Pros: Cheap. No free-tier time limits. Full root access.

Cons: Costs money. $1/month adds up to $12/year.

Hetzner ($4/month)

European VPS provider. Reliable and cheap.

Pros: Fast. Good network. EU privacy laws.

Cons: Costs money. ~$4/month for the smallest plan.

What Actually Changed My Setup

I started with GitHub Codespaces. It worked but the 60-hour limit bothered me. I tried Oracle Cloud and Google Cloud but signup kept failing. I tried Cloudflare WARP but it routes through the nearest datacenter, which is in Pakistan.

I ended up on AWS. A t2.micro in us-east-1 costs nothing for 12 months. The SSH tunnel stays alive with auto-reconnect. I wrote a bat file that starts the tunnel, starts the HTTP proxy, and launches OpenCode in one click.

Here's the key insight: the tunnel needs three things to stay alive.

  1. SSH keepalive (ServerAliveInterval=30)
  2. A wrapper script that restarts the tunnel if it dies
  3. An HTTP proxy that converts SOCKS5 to HTTP (pproxy, not http-proxy-to-socks)

The Setup I Use Now

Files on My Machine

aws-tunnel.cmd - The SSH tunnel with auto-reconnect:

 off
:loop
ssh -o ServerAliveInterval=30 -o ServerAliveCountMax=10 -o ExitOnForwardFailure=yes -i "%USERPROFILE%\proxy-key.pem" -D 1080 ubuntu@YOUR_SERVER_IP
echo SSH tunnel died. Restarting in 3 seconds...
timeout /t 3 /nobreak >nul
goto loop

opencode-proxy.cmd - Launches OpenCode with proxy:

 off
set HTTP_PROXY=http://127.0.0.1:8080
set HTTPS_PROXY=http://127.0.0.1:8080
set http_proxy=http://127.0.0.1:8080
set https_proxy=http://127.0.0.1:8080
set NO_PROXY=localhost,127.0.0.1,::1
opencode

Desktop shortcuts:

  • Start OpenCode.bat - starts tunnel + proxy + launches OpenCode
  • Stop Proxy.bat - kills everything
  • Start AWS Server.bat - starts the EC2 instance
  • Stop AWS Server.bat - stops the EC2 instance (no billing)

Common Problems and Fixes

Tunnel dies after a few minutes

The SSH connection drops because NAT/firewalls kill idle TCP connections. Fix: add ServerAliveInterval=30 to your SSH command or config.

ECONNRESET errors

The http-proxy-to-socks npm package is broken. Use pproxy instead:

pip install pproxy
python -m pproxy -l http://127.0.0.1:8080 -r socks5://127.0.0.1:1080

AionUI team leader stuck loading

Known bug in AionUI. The team leader initialization fails due to ACP permission issues. Fix: delete the team and create a new one. Clear cache:

Remove-Item "$env:USERPROFILE\.cache\opencode" -Recurse -Force
Remove-Item "$env:USERPROFILE\.local\share\opencode" -Recurse -Force

Proxy env vars don't apply to new terminals

Set them permanently with setx:

setx HTTP_PROXY "http://127.0.0.1:8080"
setx HTTPS_PROXY "http://127.0.0.1:8080"

Restart your terminal after running these.

OpenCode CLI doesn't use the proxy

Use a wrapper script (opencode-proxy.cmd) that sets env vars before launching. Setting env vars in PowerShell doesn't always propagate to child processes.

How to Get an AI Agent to Do This for You

If you're using Claude Code, Cursor, or any AI coding assistant, copy this prompt:

I need to set up an SSH tunnel proxy so I can use Muse Spark from Pakistan. Muse Spark blocks Pakistani IPs and detects VPNs, so I need to route traffic through an SSH tunnel to a server outside Pakistan.

Here's what I need you to do:

  1. Check if GitHub CLI is installed. If not, install it with winget install GitHub.cli
  2. Run gh auth login and gh auth refresh -h github.com -s codespace to authenticate
  3. Create an SSH key with ssh-keygen -t ed25519
  4. Add the public key to GitHub (Settings → SSH keys)
  5. Create a Codespace: gh cs create --repo myusername/myrepo
  6. Create an SSH tunnel script (aws-tunnel.cmd) that runs: ssh -o ServerAliveInterval=30 -o ServerAliveCountMax=10 -D 1080 ubuntu@CODESPACE_IP
  7. Install pproxy: pip install pproxy
  8. Create a wrapper script (opencode-proxy.cmd) that sets HTTP_PROXY and HTTPS_PROXY env vars to http://127.0.0.1:8080, then launches OpenCode
  9. Create desktop shortcuts for starting and stopping the proxy
  10. Test the full chain: tunnel → pproxy → OpenCode → curl https://httpbin.org/ip to verify the IP changed

The SSH tunnel needs auto-reconnect (loop script that restarts on failure). The keepalive settings prevent idle timeout. Use pproxy, not http-proxy-to-socks, because the npm package drops connections.

The SSH tunnel method works. It's not a VPN. Muse Spark treats it as normal traffic. GitHub Codespaces gives you a free server for 60 hours a month. If you need more, AWS Free Tier or Oracle Cloud handle the rest.

The trick is keeping the tunnel alive. Without keepalive and auto-reconnect, it dies every few minutes. With them, it runs indefinitely.

If you're in Pakistan and Muse Spark is giving you trouble, this is the way around it.

Tested on Windows 11 with OpenCode 1.18.16 and AionUI 2.1.61. Server IPs used: GitHub Codespaces (India), AWS us-east-1 (Virginia). Both work.

0 Upvotes

3 comments sorted by

1

u/yanpaing007 21h ago

Bro just use 9router with vercel relay

1

u/torrso 21h ago

Quite a lot of instructions for something that can be done by booting up a vps in a country that is accepted and ssh-ing in there to run opencode in terminal. That's one of the main reasons why we have terminal apps.