ttyd(1)
β¨ ttyd β the manual, but make it cute β¨
okay bestie, welcome to the ttyd(1) manual page π this is the User Manual energy, and we're about to make your terminal famous on the internet. no cap.
πΈ NAME πΈ
ttyd β share your terminal over the web π
π¦ SYNOPSIS π¦
ttyd [options] <command> [<arguments...>]
β¨ DESCRIPTION β¨
so like, ttyd is a command-line tool for sharing your terminal over the web, and it runs on nix and windows systems. she's flexible like that π«Ά and here's the feature list, because she is *stacked:
- Built on top of Libwebsockets with libuv for speed β‘
- Fully-featured terminal based on Xterm.js with CJK (Chinese, Japanese, Korean) and IME support π
- Graphical ZMODEM integration with lrzsz support
- Sixel image output support πΌοΈ
- SSL support based on OpenSSL π
- Run any custom command with options π
- Basic authentication support and many other custom options π₯
- Cross platform: macOS, Linux, FreeBSD/OpenBSD, OpenWrt/LEDE, Windows π
π OPTIONS π
every single one, bestie. no skipping. periodt.
-p,--portβ port to listen on (default:7681, use0for a random port) π²-i,--interfaceβ network interface to bind (eg:eth0), or a UNIX domain socket path (eg:/var/run/ttyd.sock)-U,--socket-ownerβ user owner of the UNIX domain socket file, when enabled (eg:user:group)-c,--credential USER[:PASSWORD]β credential for Basic Authentication (format:username:password) π-H,--auth-headerβ HTTP Header name for auth proxy; this configures ttyd to let a HTTP reverse proxy handle authentication-u,--uidβ user id to run with-g,--gidβ group id to run with-s,--signalβ signal to send to the command when exit it (default:1,SIGHUP)-w,--cwdβ working directory to be set for the child program π-a,--url-argβ allow client to send command line arguments in the URL (eg:http://localhost:7681?arg=foo&arg=bar)-W,--writableβ allow clients to write to the TTY (readonly by default) βοΈ-t,--client-optionβ send option to client (format:key=value), repeat to add more options, see CLIENT OPTIONS for details-T,--terminal-typeβ terminal type to report, default:xterm-256color-O,--check-originβ do not allow websocket connection from a different origin-m,--max-clientsβ maximum clients to support (default:0, no limit)-o,--onceβ accept only one client and exit on disconnection-q,--exit-no-connβ exit on all clients disconnection-B,--browserβ open terminal with the default system browser π-I,--indexβ customindex.htmlpath-b,--base-pathβ expected base path for requests coming from a reverse proxy (eg:/mounted/here, max length:128)-P,--ping-intervalβ websocket ping interval (sec) (default:5) π-6,--ipv6β enable IPv6 support-S,--sslβ enable SSL-C,--ssl-certβ SSL certificate file path-K,--ssl-keyβ SSL key file path-A,--ssl-caβ SSL CA file path for client certificate verification-d,--debugβ set log level (default:7)-v,--versionβ print the version and exit-h,--helpβ print this text and exit
π CLIENT OPTIONS π
so ttyd has a little mechanism where it passes server-side command-line arguments to the browser page, and that's what we call client options π
-t,--client-optionβ send option to client (format:key=value), repeat to add more options
π Basic usage π
-t rendererType=canvasβ use the canvas renderer for xterm.js (default:webgl) π¨-t disableLeaveAlert=trueβ disable the leave page alert-t disableResizeOverlay=trueβ disable the terminal resize overlay-t disableReconnect=trueβ prevent the terminal from reconnecting on connection error/close-t enableZmodem=trueβ enable ZMODEM / lrzsz file transfer support π¦-t enableTrzsz=trueβ enable trzsz file transfer support π¦-t enableSixel=trueβ enable Sixel image output support (Usage)-t titleFixed=helloβ set a fixed title for the browser window-t fontSize=20β change the font size of the terminal π
π« Advanced usage π«
you can use the client option to change all the settings of xterm defined in ITerminalOptions, examples:
-t cursorStyle=barβ set cursor style tobar-t lineHeight=1.5β set line-height to1.5-t 'theme={"background": "green"}'β set background color to green π
to try the example options above, run:
ttyd -t cursorStyle=bar -t lineHeight=1.5 -t 'theme={"background": "green"}' bash
π₯ EXAMPLES π₯
ttyd starts a web server at port 7681 by default, and you can use the -p option to change it. the command will be started with arguments as options. for example, run:
ttyd -p 8080 bash -x
then open http://localhost:8080 with a browser, and you will get a bash shell with debug mode enabled. more examples:
- if you want to login with your system accounts on the web browser, run
ttyd login. - you can even run a none shell command like
vim, try:ttyd vim, and the web browser will show you a vim editor π - sharing single process with multiple clients:
ttyd tmux new -A -s ttyd vim, runtmux new -A -s ttydto connect to the tmux session from terminal.
π SSL how-to π
generate SSL CA and self signed server/client certificates:
# CA certificate (FQDN must be different from server/client)
openssl genrsa -out ca.key 2048
openssl req -new -x509 -days 365 -key ca.key -subj "/C=CN/ST=GD/L=SZ/O=Acme, Inc./CN=Acme Root CA" -out ca.crt
# server certificate (for multiple domains, change subjectAltName to: DNS:example.com,DNS:www.example.com)
openssl req -newkey rsa:2048 -nodes -keyout server.key -subj "/C=CN/ST=GD/L=SZ/O=Acme, Inc./CN=localhost" -out server.csr
openssl x509 -sha256 -req -extfile <(printf "subjectAltName=DNS:localhost") -days 365 -in server.csr -CA ca.crt -CAkey ca.key -CAcreateserial -out server.crt
# client certificate (the p12/pem format may be useful for some clients)
openssl req -newkey rsa:2048 -nodes -keyout client.key -subj "/C=CN/ST=GD/L=SZ/O=Acme, Inc./CN=client" -out client.csr
openssl x509 -req -days 365 -in client.csr -CA ca.crt -CAkey ca.key -CAcreateserial -out client.crt
openssl pkcs12 -export -clcerts -in client.crt -inkey client.key -out client.p12
openssl pkcs12 -in client.p12 -out client.pem -clcerts
then start ttyd:
ttyd --ssl --ssl-cert server.crt --ssl-key server.key --ssl-ca ca.crt bash
you may want to test the client certificate verification with curl(1):
curl --insecure --cert client.p12[:password] -v https://localhost:7681
if you don't want to enable client certificate verification, remove the --ssl-ca option.
π³ Docker and ttyd π³
Docker containers are jailed environments which are more secure, and this is useful for protecting the host system. you may use ttyd with docker like this:
- sharing single docker container with multiple clients:
docker run -it --rm -p 7681:7681 tsl0922/ttyd. - creating new docker container for each client:
ttyd docker run -it --rm ubuntu.
π Nginx reverse proxy π
sample config to proxy ttyd under the /ttyd path:
location ~ ^/ttyd(.*)$ {
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_pass http://127.0.0.1:7681/$1;
}
π AUTHOR π
Shuanglei Tao <tsl0922@gmail.com> β visit https://github.com/tsl0922/ttyd to get more information and report bugs π
and that's the whole manual, bestie π this is ttyd version ttyd(1) from way back in September 2016 β iconic behavior honestly. now go share that terminal, you main character π«Άβ¨
π¦ where this page comes from
- alpine 3.24: ttyd-doc 1.7.7-r0 Β· MIT
- arch rolling: ttyd 1.7.7-3 Β· MIT
- epel 10: ttyd 1.7.7-2.el10_1 Β· MIT
- epel 9: ttyd 1.7.7-1.el9 Β· MIT
- fedora 43: ttyd 1.7.7-7.fc43 Β· MIT
- fedora 44: ttyd 1.7.7-9.fc44 Β· MIT
- nixpkgs unstable: ttyd 1.7.7
- ubuntu questing: ttyd 1.7.7-4
- ubuntu resolute: ttyd 1.7.7-4build1 Β· MIT
- ubuntu stonking: ttyd 1.7.7-4build2 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms