Skills2026年5月17日·1 分钟阅读

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.

Agent 就绪

先审查再安装

这个资产需要先审查。复制的指令会要求 Agent dry-run、列出写入项,确认后再继续。

Needs Confirmation · 66/100策略:需确认
Agent 入口
任意 MCP/CLI Agent
类型
Skill
安装
Single
信任
信任等级:Established
入口
ttyd Overview
先审查命令
npx -y tokrepo@latest install 134a2cb4-51c9-11f1-9bc6-00163e2b0d79 --target codex

先 dry-run,确认写入项后再运行此命令。

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 <command> 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

讨论

登录后参与讨论。
还没有评论,来写第一条吧。

相关资产