Ttyd - Part Your Final Over The Web
ttyd is a unproblematic command-line tool for sharing final over the web, inspired past times GoTTY.
Features
- Built on top of Libwebsockets alongside C for speed
- Fully-featured final based on Xterm.js alongside CJK in addition to IME support
- Graphical ZMODEM integration alongside lrzsz support
- SSL back upward based on OpenSSL
- Run whatsoever custom ascendance alongside options
- Basic authentication back upward in addition to many other custom options
- Cross platform: macOS, Linux, FreeBSD/OpenBSD, OpenWrt/LEDE, Windows
Installation
Install on macOS
Install alongside homebrew:
brew install ttyd
Install on Linux
- Binary version: download from the releases page.
- Build from source (debian/ubuntu):
sudo apt-get install cmake g++ pkg-config git vim-common libwebsockets-dev libjson-c-dev libssl-dev git clone https://github.com/tsl0922/ttyd.git cd ttyd && mkdir gear upward && cd gear upward cmake .. brand && brand install
libwebsockets-dev
packet is outdated.
- Install on Gentoo: clone the repo at https://bitbucket.org/mgpagano/ttyd/src/master/ in addition to follow the directions here for creating a local repository.
Install on Windows
ttyd tin endure built alongside MSYS2 on windows, The gear upward instructions is here.
NOTE: Native windows console programs may non operate correctly due to pty incompatibility issues. As a workaround, yous tin purpose winpty every bit a wrapper to invoke the windows program, eg: ttyd winpty cmd
.
Install on OpenWrt/LEDE
LEDE
17.01.0
in addition to later:opkg install ttyd
Usage
Command-line Options
ttyd is a tool for sharing final over the spider web USAGE: ttyd [options] [] VERSION: 1.4.2 OPTIONS: -p, --port Port to head (default: 7681, purpose `0` for random port) -i, --interface Network interface to bind (eg: eth0), or UNIX domain socket path (eg: /var/run/ttyd.sock) -c, --credential Credential for Basic Authentication (format: username:password) -u, --uid User id to run alongside -g, --gid Group id to run alongside -s, --signal Signal to post to the ascendance when teach out it (default: 1, SIGHUP) -r, --reconnect Time to reconnect for the customer inwards seconds (default: 10) -R, --readonly Do non permit clients to write to the TTY -t, --client-option Send pick to customer (format: key=value), repeat to add together to a greater extent than options -T, --terminal-type Termin al type to report, default: xterm-256color -O, --check-origin Do non permit websocket connectedness from unlike root -m, --max-clients Maximum clients to back upward (default: 0, no limit) -o, --once Accept entirely i customer in addition to teach out on disconnection -B, --browser Open final alongside the default organization browser -I, --index Custom index.html path -6, --ipv6 Enable IPv6 back upward -S, --ssl Enable SSL -C, --ssl-cert SSL certificate file path -K, --ssl-key SSL cardinal file path -A, --ssl-ca SSL CA file path for customer certificate verification -d, --debug Set log score (default: 7) -v, --version Print the version in addition to teach out -h, --help Print this text in addition to teach out Vi sit down https://github.com/tsl0922/ttyd to teach to a greater extent than information in addition to study bugs.
Example Usage
ttyd starts spider web server at port
7681
past times default, yous tin purpose the -p
pick to alter it, the command
volition endure started alongside arguments
every bit options. For example, run:ttyd -p 8080 bash -x
More Examples:
- If yous desire to login alongside your organization accounts on the spider web browser, run
ttyd login
. - You tin fifty-fifty run a none crunch ascendance similar vim, try:
ttyd vim
, the spider web browser volition demo yous a vim editor. - Sharing unmarried procedure alongside multiple clients:
ttyd tmux novel -A -s ttyd vim
, runtmux novel -A -s ttyd
to connect to the tmux session from terminal.
Browser Support
Modern browsers, See Browser Support.
SSL how-to
Generate SSL CA in addition to self signed server/client certificates:
# CA certificate (FQDN must endure unlike 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, alter 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 -req -extfile <(printf "subjectAltName=DNS:localhost") -days 365 -in server.csr -CA ca.crt -CAkey ca.key -CAcreateserial -out server.crt # customer certificate (the p12/pem format may endure useful for only about 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 clie nt.key -out client.p12 openssl pkcs12 -in client.p12 -out client.pem -clcerts
ttyd --ssl --ssl-cert server.crt --ssl-key server.key --ssl-ca ca.crt bash
curl
:curl --insecure --cert client.p12[:password] -v https://localhost:7681
--ssl-ca
option.Docker in addition to ttyd
Docker containers are jailed environments which are to a greater extent than secure, this is useful for protecting the host system, yous may purpose ttyd alongside docker similar this:
- Sharing unmarried docker container alongside multiple clients:
docker run -it --rm -p 7681:7681 tsl0922/ttyd
. - Creating novel docker container for each client:
ttyd docker run -it --rm ubuntu
.
Credits
- GoTTY: ttyd is a port of GoTTY to
C
linguistic communication alongside many improvements. - Libwebsockets: is used to gear upward the websocket server.
- Xterm.js: is used to run the final emulator on the web, hterm is used previously.