Linux command
ttyd 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Share a bash shell
ttyd bash
Share on a specific port
ttyd -p [8080] bash
Share with authentication
ttyd -c [username]:[password] bash
Share in read-only mode
ttyd -R bash
Share vim
ttyd vim [file.txt]
Share a tmux session
ttyd tmux new -A -s [session_name]
Share with SSL
ttyd --ssl --ssl-cert [cert.pem] --ssl-key [key.pem] bash
Bind to specific interface
ttyd -i [eth0] bash
说明
ttyd shares a terminal session over the web using WebSockets. It starts a web server (default port 7681) that serves a terminal interface accessible from any web browser. This enables remote terminal access, collaboration, and demonstrations without requiring SSH setup. Any command can be shared, not just shells. Running ttyd vim provides a web-based vim editor. Combining with tmux allows multiple users to share the same session simultaneously. The tool supports basic authentication via -c, SSL encryption for secure connections, and can restrict clients to read-only mode. It handles Unicode, CJK characters, and supports file transfer via ZMODEM. ttyd works on Linux, macOS, FreeBSD, OpenBSD, and Windows.
参数
- -p, --port _port_
- Port to listen on (default: 7681, use 0 for random)
- -i, --interface _interface_
- Network interface to bind (e.g., eth0) or Unix socket path
- -c, --credential _user:pass_
- Basic authentication credentials
- -u, --uid _uid_
- User ID to run command with
- -g, --gid _gid_
- Group ID to run command with
- -R, --readonly
- Do not allow clients to write to the TTY
- -W, --writable
- Allow clients to write (readonly by default with multiple clients)
- -s, --signal _signal_
- Signal to send on exit (default: 1, SIGHUP)
- --ssl
- Enable SSL/TLS encryption
- --ssl-cert _file_
- SSL certificate file path
- --ssl-key _file_
- SSL key file path
- -O, --once
- Accept only one client and exit when disconnected
- -d, --debug _level_
- Set log level (0-9, default: 7)
FAQ
What is the ttyd command used for?
ttyd shares a terminal session over the web using WebSockets. It starts a web server (default port 7681) that serves a terminal interface accessible from any web browser. This enables remote terminal access, collaboration, and demonstrations without requiring SSH setup. Any command can be shared, not just shells. Running ttyd vim provides a web-based vim editor. Combining with tmux allows multiple users to share the same session simultaneously. The tool supports basic authentication via -c, SSL encryption for secure connections, and can restrict clients to read-only mode. It handles Unicode, CJK characters, and supports file transfer via ZMODEM. ttyd works on Linux, macOS, FreeBSD, OpenBSD, and Windows.
How do I run a basic ttyd example?
Run `ttyd bash` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -p, --port _port_ do in ttyd?
Port to listen on (default: 7681, use 0 for random)