clsh uses a tunnel to expose your local terminal server to your phone. By default, it uses a free SSH tunnel via localhost.run, which works with zero configuration but gives you a new URL every time you restart.
For a permanent URL that survives restarts (ideal for saving as a PWA on your phone's home screen), set up ngrok.
ngrok creates a secure HTTPS tunnel from a public URL to your local clsh server. With a free static domain, you get the same URL every time, so your phone's saved bookmark/PWA always connects.
Go to ngrok.com and sign up. The free tier includes everything you need:
- 1 static domain
- Unlimited bandwidth for personal use
npx clsh-dev setupThis will prompt you for:
- Your authtoken (from dashboard.ngrok.com/get-started/your-authtoken)
- Your static domain (from dashboard.ngrok.com/domains)
The wizard saves these to ~/.clsh/config.json so you only need to do this once.
npx clsh-devYou should see your permanent ngrok URL in the QR code output. Scan it on your phone and save it to your home screen.
If you prefer to set things up manually instead of using the wizard:
Create ~/.clsh/config.json:
{
"ngrokAuthtoken": "your-authtoken-here",
"ngrokStaticDomain": "your-name.ngrok-free.dev"
}NGROK_AUTHTOKEN=your-authtoken-here NGROK_STATIC_DOMAIN=your-name.ngrok-free.dev npx clsh-devIf you cloned the repo, add to your .env file at the repo root:
NGROK_AUTHTOKEN=your-authtoken-here
NGROK_STATIC_DOMAIN=your-name.ngrok-free.dev
When multiple sources are set, clsh uses this priority (highest wins):
- Environment variables
.envfile (repo root or current directory)~/.clsh/config.json- Defaults (SSH tunnel, port 4030)
Make sure your authtoken is correct. You can re-run npx clsh-dev setup to update it.
Free ngrok URLs show a browser warning page on first visit. This only appears once per session in a browser. The clsh web app connects via WebSocket, which is not affected by the interstitial.
Force the SSH tunnel method:
TUNNEL=ssh npx clsh-devOr for local network only (no internet tunnel):
TUNNEL=local npx clsh-devVisit dashboard.ngrok.com/get-started/your-authtoken.
Visit dashboard.ngrok.com/domains. Click "New Domain" if you don't have one yet (one free domain per account).