Shell in a Browser: Terminal Sharing for AI Developer Tools
By: Evgeny Padezhnov
A full shell session fits in a browser tab. One binary, one command, one URL — and a teammate on another continent types into the same terminal. Screen sharing over video calls compresses text into blur and turns copy-paste into dictation. Terminal-sharing tools solve the actual problem: two people, one shell, real text. The category has quietly become part of the ai developer tools stack, because coding agents now run long sessions in terminals that someone should be able to watch.
How a Shell Ends Up in a Browser Tab
The mechanism is simpler than it looks. Three pieces do all the work.
First, a pseudo-terminal (PTY) on the server. The sharing tool spawns your shell inside a PTY, exactly like ssh or tmux does. The shell cannot tell the difference.
Second, a transport. Almost every browser-based tool uses WebSockets. Keystrokes travel up the socket as bytes. Terminal output travels back down as bytes. No rendering happens on the server.
Third, a terminal emulator in the browser. The dominant one is xterm.js — the same library that renders the integrated terminal in VS Code. It interprets ANSI escape codes, draws the grid, and handles input.
In plain terms: the browser becomes a thin terminal emulator, and the network carries raw terminal bytes in both directions. No video encoding, no pixels. A session over a slow connection stays sharp because text is cheap. This is also why htop, vim, and full-screen TUIs work correctly in a shared browser terminal — the escape codes arrive intact.
ttyd: One Binary, One Port, Full Shell
ttyd is the workhorse of the self-hosted category. It is written in C on top of libwebsockets, ships as a single binary, and serves xterm.js itself. Its predecessor GoTTY (written in Go) popularized the idea, but GoTTY development stalled years ago. ttyd is the maintained option.
Basic usage:
ttyd -W bash
# shell now served on http://localhost:7681
Default port is 7681. Recent ttyd versions start clients in read-only mode; the -W flag enables input. That default matters — a read-only broadcast is often exactly what a demo or incident review needs.
Useful flags for real use:
# basic auth + writable shell
ttyd -c admin:s3cret -W bash
# bind to loopback only, share a tmux session
ttyd -i lo -W tmux new -A -s shared
# native TLS
ttyd --ssl --ssl-cert cert.pem --ssl-key key.pem -W bash
The tmux variant is the pattern worth memorizing. tmux new -A -s shared attaches to an existing session or creates one. Local user and browser viewers then see the same live session. The local user keeps working in a normal terminal; the browser is just another window onto the same PTY.
ttyd fits a specific case: you control the server, the port is reachable, and you want zero third parties in the path. In practice that means internal networks, VPNs, or a reverse proxy you already run.
tmate, sshx, upterm: Sharing Without Open Ports
Most laptops sit behind NAT. No inbound port means no ttyd link. A second family of tools solves this by connecting outward to a relay.
tmate is a fork of tmux. Run tmate, and it dials out to tmate.io relay servers, then prints connection strings:
tmate
# ssh session: ssh [email protected]
# web session: https://tmate.io/t/xyz123
# read-only web: https://tmate.io/t/ro-xyz123
You get four links: SSH and web, each in writable and read-only variants. Because it is tmux underneath, all tmux keybindings and window management work. The relay is self-hostable via tmate-server, which removes the third party from the path.
sshx is the newer entry, written in Rust. Install and run:
curl -sSf https://sshx.io/get | sh
sshx
# https://sshx.io/s/... — share this link
It targets collaboration rather than plain mirroring: multiple participants, each with a visible cursor, multiple terminals on one shared canvas, and a chat sidebar. The project states that sessions are end-to-end encrypted, so the relay sees ciphertext. For pair debugging with more than two people, it is the most comfortable of the three.
upterm is the open-source, SSH-only sibling. upterm host -- bash shares a session through an SSH relay. No browser component — viewers need an SSH client. It trades convenience for a smaller attack surface.
Key point: relay-based tools work from behind NAT, corporate firewalls, and hotel Wi-Fi, with no port forwarding and no DNS. The cost is a third party in the connection path. For anything sensitive, self-host the relay or fall back to ttyd inside a VPN.
Why AI Coding Tools Changed the Use Case
Terminal sharing existed for a decade as a pair-programming niche. AI agents gave it a second job.
Many of the strongest AI tools for coding are terminal-first. Claude Code lives entirely in the terminal, aider runs as a CLI, and long agent sessions produce a scrolling record of commands, diffs, and test runs. That record is worth watching in real time — an agent refactoring for twenty minutes is exactly the kind of process a second pair of eyes should supervise.
The working pattern:
# on the dev box
tmux new -s agent
claude # or aider, or any CLI agent
# expose it read-only
ttyd -i lo tmux attach -t agent -r
# then reverse-proxy 127.0.0.1:7681 with auth
A reviewer opens a browser tab and watches the agent work, without SSH access to the machine and without the ability to type. Read-only is the correct default here: supervision does not require input. The same setup turns an agent session into a live demo for a teammate who wants to see what a locked-in AI IDE stack looks like day to day.
There is a second AI-adjacent case: remote pairing on agent prompts. Two people share one writable session, one drives the agent, the other corrects course. A video call carries voice; the terminal carries truth.
Security: A Shared Shell Is Remote Code Execution by Design
A writable browser terminal is, by definition, remote code execution as a service. Every hardening decision follows from that sentence.
Common mistake: running ttyd -W bash bound to all interfaces on a public server, with no auth. Device search engines index exposed web terminals, and an open ttyd instance hands out a shell to anyone who finds the port. This is not a theoretical risk — it is the most frequent misconfiguration in this tool category.
The minimum viable hardening list:
- Bind to loopback.
ttyd -i lo ..., then put nginx or Caddy in front with TLS and auth. Never expose port 7681 directly. - Read-only unless writing is required. Omit
-W. Most supervision and demo cases never need viewer input. - Authenticate.
-c user:passis the floor. An identity-aware proxy (Cloudflare Access, oauth2-proxy, Tailscale) is better because links stop being bearer tokens. - Run as a low-privilege user. Share
bashunder a dedicated account, not root. A shared shell inherits every permission of the user running it. - Kill sessions after use. Relay links from tmate and sshx die when the process exits. ttyd keeps serving until stopped.
pkill ttydbelongs at the end of every session.
For relay tools, the trust question is different: the relay operator sits in the path. tmate solves it with self-hosting. sshx answers with end-to-end encryption. upterm narrows exposure to SSH. Pick based on what your threat model actually contains, not on what a README promises.
Where Terminal Sharing Fits Among Remote Work Tools
Video calls, chat, and shared documents cover most distributed collaboration. Terminals are the gap. The best tools for remote work in this niche split cleanly by scenario:
| Tool | Transport | Browser viewer | Inbound port needed | Best for |
|---|---|---|---|---|
| ttyd | WebSocket, self-hosted | Yes | Yes (or proxy/VPN) | Internal infra, agent supervision |
| tmate | Outbound to relay | Yes | No | Instant ad-hoc pairing |
| sshx | Outbound to relay, E2E encrypted | Yes | No | Multi-person collaboration |
| upterm | Outbound SSH relay | No | No | Security-conscious pairing |
| VS Code tunnels | Outbound to Microsoft | Yes (vscode.dev) | No | Full editor plus terminal |
VS Code tunnels deserve the footnote: code tunnel exposes a whole workspace — editor, files, and terminal — through vscode.dev with GitHub authentication. It is heavier than a shell share but covers the "I need your whole environment" case with auth built in.
Selection heuristic: control both machines and a network path — ttyd behind a proxy. Need a link in ten seconds — tmate. Three or more participants — sshx. Distributed teams already report that good tooling closes most of the distance remote work creates; a shared terminal closes the last technical gap, the one video calls handle worst.
One honest limitation: none of these tools handle flaky mobile connections gracefully. A dropped WebSocket means a reconnect, and ttyd does not resume scrollback state — tmux underneath is what preserves the session. Without tmux or screen in the stack, a network blip costs you the shared context. Put tmux under every share that matters.
What to Try Right Now
Try it: open two terminals on one machine. In the first, run tmate (install: brew install tmate or apt install tmate). Copy the read-only web link it prints. Open that link in a phone browser. Type htop in the terminal and watch it render, live and sharp, on the phone. That two-minute test demonstrates the whole category — and the next time a debugging session stalls on "can you share your screen," you will send a link instead.
Information is accurate as of the publication date. Terms, prices, and regulations may change — verify with relevant professionals.