LinuxCommandLibrary

ttyd

Share terminal sessions over the web

TLDR

Share a bash shell over the web

$ ttyd bash
copy
Share on a specific port
$ ttyd -p [8080] bash
copy
Share with authentication
$ ttyd -c [username]:[password] bash
copy
Share in read-only mode
$ ttyd -R bash
copy
Share vim editor over the web
$ ttyd vim [file.txt]
copy
Share a tmux session with multiple clients
$ ttyd tmux new -A -s [session_name]
copy
Share with SSL encryption
$ ttyd --ssl --ssl-cert [cert.pem] --ssl-key [key.pem] bash
copy
Bind to specific interface
$ ttyd -i [eth0] bash
copy

SYNOPSIS

ttyd [options] command [arguments...]

DESCRIPTION

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.

PARAMETERS

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

CAVEATS

By default, ttyd provides no authentication; always use -c or firewall rules in production. Multiple clients connecting without tmux each get separate sessions. The default port 7681 may need firewall configuration for external access.

HISTORY

ttyd was created by Shuanglei Tao (tsl0922) and first released around 2016. Written in C, it uses libwebsockets for WebSocket communication and xterm.js for the browser-based terminal. The project was inspired by older tools like shellinabox but with modern web technologies.

SEE ALSO

tmux(1), screen(1), gotty(1), ssh(1)

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community