# ttyd — Share Your Terminal over the Web > ttyd is a lightweight tool that turns a terminal session into a web application, allowing browser-based access to any command-line program. ## Install Save in your project root: # ttyd — Share Your Terminal over the Web ## Quick Use ```bash brew install ttyd ttyd bash # Open http://localhost:7681 in your browser ``` ## Introduction ttyd exposes a terminal session as a web page, letting anyone with a browser interact with a command-line program running on a remote machine. It is useful for sharing shells, running interactive tools in kiosk mode, or building browser-based terminal interfaces. ## What ttyd Does - Serves any terminal program (bash, htop, vim, etc.) via a web browser - Uses WebSocket for low-latency bidirectional communication - Supports multiple concurrent client connections - Provides read-only mode for safe observation without input - Works with SSL/TLS for encrypted sessions ## Architecture Overview ttyd is written in C and uses libwebsockets for the WebSocket server and xterm.js for the browser-side terminal emulator. When a client connects, ttyd spawns a new pseudo-terminal (pty) running the specified command and bridges I/O between the pty and the WebSocket. The binary is small and has minimal runtime dependencies. ## Self-Hosting & Configuration - Install via Homebrew, apt, or download a static binary from Releases - Run `ttyd ` to start the server on port 7681 - Use `-p` to change the listening port and `-i` to bind to a specific interface - Enable TLS with `--ssl-cert` and `--ssl-key` for production deployments - Add basic authentication with `-c username:password` ## Key Features - Sub-megabyte static binary that compiles on Linux, macOS, and FreeBSD - Full terminal emulation in the browser via xterm.js, including 256-color and Unicode - Read-only mode (`-R`) for safe live-streaming of terminal output - Client-side URL arguments to set terminal size, font, and theme - Can run behind a reverse proxy (Nginx, Caddy) with WebSocket pass-through ## Comparison with Similar Tools - **sshx** — collaborative terminal sharing with multiplayer cursors; ttyd is a simpler one-command web terminal - **Gotty** — similar concept but unmaintained since 2017; ttyd is actively developed - **Wetty** — Node.js-based web terminal tied to SSH; ttyd is a lightweight C binary serving any command - **Shellinabox** — legacy web terminal; ttyd offers modern xterm.js rendering and WebSocket transport ## FAQ **Q: Can multiple users connect at the same time?** A: Yes. Each connection gets its own pty by default. Use `--once` to limit to a single session. **Q: Is it safe to expose ttyd to the internet?** A: Use TLS and authentication at minimum. For public use, place it behind a reverse proxy with additional access controls. **Q: Does it support copy and paste?** A: Yes. The xterm.js frontend supports clipboard integration in modern browsers. **Q: Can I customize the web UI appearance?** A: Yes. Pass xterm.js options via URL query parameters or use a custom index.html with `--base-path`. ## Sources - https://github.com/tsl0922/ttyd - https://tsl0922.github.io/ttyd --- Source: https://tokrepo.com/en/workflows/asset-134a2cb4 Author: AI Open Source