Update to 1.6.0

This commit is contained in:
Shuanglei Tao
2020-03-14 12:53:25 +08:00
parent dc20b9c2f5
commit d9b83cee39

View File

@@ -15,19 +15,19 @@
<a href="https://github.com/tsl0922/ttyd" class="github-corner" aria-label="View source on Github"><svg width="80" height="80" viewBox="0 0 250 250" style="fill:#fff; color:#151513; position: absolute; top: 0; border: 0; right: 0;" aria-hidden="true"><path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path><path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path><path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"></path></svg></a><style>.github-corner:hover .octo-arm{animation:octocat-wave 560ms ease-in-out}@keyframes octocat-wave{0%,100%{transform:rotate(0)}20%,60%{transform:rotate(-25deg)}40%,80%{transform:rotate(10deg)}}@media (max-width:500px){.github-corner:hover .octo-arm{animation:none}.github-corner .octo-arm{animation:octocat-wave 560ms ease-in-out}}</style>
<div class="main container">
<h1>ttyd - Share your terminal over the web <a href="https://travis-ci.org/tsl0922/ttyd"><img src="https://camo.githubusercontent.com/50cc34efea561009d960259340e86c1e47249920/68747470733a2f2f7472617669732d63692e6f72672f74736c303932322f747479642e7376673f6272616e63683d6d6173746572" alt="Build Status" data-canonical-src="https://travis-ci.org/tsl0922/ttyd.svg?branch=master" style="max-width:100%;"></a></h1>
<p>ttyd is a simple command-line tool for sharing terminal over the web, inspired by <a href="https://github.com/yudai/gotty">GoTTY</a>.</p>
<p>ttyd is a simple command-line tool for sharing terminal over the web.</p>
<p>
<a href="screenshot.gif" target="_blank"><img src="screenshot.gif" alt="screenshot" style="max-width:100%;"></a>
</p>
<h1>Features</h1>
<ul>
<li>Built on top of <a href="https://libwebsockets.org">Libwebsockets</a> with C for speed</li>
<li>Built on top of <a href="https://libwebsockets.org">Libwebsockets</a> with <a href="https://libuv.org">libuv</a> for speed</li>
<li>Fully-featured terminal based on <a href="https://github.com/sourcelair/xterm.js">Xterm.js</a> with CJK (<em>Chinese, Japanese, Korean</em>) and IME support</li>
<li>Graphical <a href="https://en.wikipedia.org/wiki/ZMODEM">ZMODEM</a> integration with <a href="https://ohse.de/uwe/software/lrzsz.html">lrzsz</a> support</li>
<li>SSL support based on <a href="https://www.openssl.org">OpenSSL</a></li>
<li>Run any custom command with options</li>
<li>Basic authentication support and many other custom options</li>
<li>Cross platform: macOS, Linux, FreeBSD, <a href="https://openwrt.org">OpenWrt</a>/<a href="https://www.lede-project.org">LEDE</a>, Windows</li>
<li>Cross platform: macOS, Linux, FreeBSD/OpenBSD, <a href="https://openwrt.org">OpenWrt</a>, Windows</li>
</ul>
<h1>Installation</h1>
<h2>Install on macOS</h2>
@@ -35,34 +35,23 @@
<pre><code class="language-bash">brew install ttyd</code></pre>
<h2>Install on Linux</h2>
<ul>
<li>
<p>Install from ppa (ubuntu 16.04 and later):</p>
<pre><code class="language-bash">sudo apt-get install -y software-properties-common
sudo add-apt-repository ppa:tsl0922/ttyd-dev
sudo apt-get update
sudo apt-get install ttyd</code></pre>
</li>
<li>
<p>Build from source (debian/ubuntu):</p>
<pre><code class="language-bash">sudo apt-get install cmake g++ pkg-config git vim-common libwebsockets-dev libjson-c-dev libssl-dev
<li><p>Binary version (recommended): download from the <a href="https://github.com/tsl0922/ttyd/releases">releases</a> page.</p></li>
<li><p>Build from source (debian/ubuntu):</p>
<pre><code class="language-bash">sudo apt-get install build-essential cmake git libjson-c-dev libwebsockets-dev
git clone https://github.com/tsl0922/ttyd.git
cd ttyd && mkdir build && cd build
cmake ..
make && make install</code></pre>
<p>You may need to compile/install <a href="https://libwebsockets.org">libwebsockets</a> from source if
the <code>libwebsockets-dev</code> package is outdated.</p>
<p>You may also need to compile/install <a href="https://libwebsockets.org">libwebsockets</a> from source if the <code>libwebsockets-dev</code> package is outdated.</p>
</li>
<li>
<p>Install on Gentoo: clone the <a href="https://bitbucket.org/mgpagano/ttyd/src/master">repo</a> and follow the directions <a href="https://wiki.gentoo.org/wiki/Custom_repository#Creating_a_local_repository">here</a>.</p>
</li>
</ul>
<h2>Install on Windows</h2>
<p>ttyd can be built with <a href="http://msys2.github.io">MSYS2</a> on windows, The build instructions is <a href="https://github.com/tsl0922/ttyd/tree/master/msys2">here</a>.</p>
<blockquote>
<strong>NOTE:</strong> Native windows console programs may not work correctly due to <a href="https://github.com/mintty/mintty/blob/master/wiki/Tips.md#inputoutput-interaction-with-alien-programs">pty incompatibility issues</a>.
<br> As a workaround, you can use <a href="https://github.com/rprichard/winpty">winpty</a> as a wrapper to invoke the windows program, eg: <code>ttyd winpty cmd</code>.
</blockquote>
<h2>Install on OpenWrt/LEDE</h2>
<p><a href="https://www.lede-project.org">LEDE</a> <code>17.01.0</code> and later:</p>
<p><a href="https://github.com/tsl0922/ttyd/wiki/Compile-on-Windows">Compile on Windows</a>.</p>
<h2>Install on OpenWrt</h2>
<pre><code class="language-bash">opkg install ttyd</code></pre>
<p>If the install command fails, you can <a href="https://github.com/tsl0922/ttyd/tree/master/openwrt">compile it yourself</a>.</p>
<h1>Usage</h1>
<h2>Command-line Options</h2>
<pre><code>ttyd is a tool for sharing terminal over the web
@@ -71,7 +60,7 @@ USAGE:
ttyd [options] &lt;command&gt; [&lt;arguments...&gt;]
VERSION:
1.4.0
1.6.0
OPTIONS:
-p, --port Port to listen (default: 7681, use `0` for random port)
@@ -80,14 +69,17 @@ OPTIONS:
-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)
-r, --reconnect Time to reconnect for the client in seconds (default: 10)
-a, --url-arg Allow client to send command line arguments in URL (eg: http://localhost:7681?arg=foo&arg=bar)
-R, --readonly Do not allow clients to write to the TTY
-t, --client-option Send option to client (format: key=value), repeat to add more options
-T, --terminal-type Terminal type to report, default: xterm-256color
-O, --check-origin Do not allow websocket connection from different origin
-m, --max-clients Maximum clients to support (default: 0, no limit)
-o, --once Accept only one client and exit on disconnection
-B, --browser Open terminal with the default system browser
-I, --index Custom index.html path
-b, --base-path Expected base path for requests coming from a reverse proxy (eg: /mounted/here)
-6, --ipv6 Enable IPv6 support
-S, --ssl Enable SSL
-C, --ssl-cert SSL certificate file path
-K, --ssl-key SSL key file path
@@ -98,45 +90,13 @@ OPTIONS:
Visit https://github.com/tsl0922/ttyd to get more information and report bugs.
</code></pre>
<h2>Example Usage</h2>
<p>ttyd starts web server at port <code>7681</code> by default, you can use the <code>-p</code> option to change it, the <code>command</code> will be started with <code>arguments</code> as options. For example, run:</p>
<pre><code class="language-bash">ttyd -p 8080 bash -x</code></pre>
<p>Then open <a href="http://localhost:8080">http://localhost:8080</a> with a broswer, you will get a bash shell with debug mode enabled.</p>
<p><strong>More Examples:</strong></p>
<p>Read the example usage on the <a href="https://github.com/tsl0922/ttyd/wiki/Example-Usage">wiki</a>.</p>
<h2>Browser Support</h2>
<p>Modern browsers, See <a href="https://github.com/xtermjs/xterm.js#browser-support">Browser Support</a>.</p>
<h2>Alternatives</h2>
<ul>
<li>If you want to login with your system accounts on the web broswer, run <code>ttyd login</code>.</li>
<li>You can even run a none shell command like vim, try: <code>ttyd vim</code>, the web broswer will show you a vim editor.</li>
<li>Sharing single process with multiple clients: <code>ttyd tmux new -A -s ttyd vim</code>, run <code>tmux new -A -s ttyd</code> to connect to the tmux session from terminal.</li>
</ul>
<h2>SSL how-to</h2>
<p>Generate SSL CA and self signed server/client certificates:</p>
<pre><code class="language-bash"># CA certificate (FQDN must be different from server/client)
openssl genrsa -out ca.key 4096
openssl req -new -x509 -days 365 -key ca.key -out ca.crt
# server certificate
openssl req -newkey rsa:2048 -nodes -keyout server.key -out server.csr
openssl x509 -req -days 365 -in server.csr -CA ca.crt -CAkey ca.key -set_serial 01 -out server.crt
# client certificate (the p12/pem format may be useful for some clients)
openssl req -newkey rsa:2048 -nodes -keyout client.key -out client.csr
openssl x509 -req -days 365 -in client.csr -CA ca.crt -CAkey ca.key -set_serial 02 -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</code></pre>
<p>Then start ttyd:</p>
<pre><code class="language-bash">ttyd --ssl --ssl-cert server.crt --ssl-key server.key --ssl-ca ca.crt bash</code></pre>
<p>You may want to test the client certificate verification with <code>curl</code>:</p>
<pre><code class="language-bash">curl --insecure --cert client.p12[:password] -v https://localhost:7681</code></pre>
<p>If you don't want to enable client certificate verification, remove the <code>--ssl-ca</code> option.</p>
<h2>Docker and ttyd</h2>
<p>Docker containers are jailed environments which are more secure, this is useful for protecting the host system, you may use ttyd with docker like this:</p>
<ul>
<li>Sharing single docker container with multiple clients: <code>docker run -it --rm -p 7681:7681 tsl0922/ttyd</code>.</li>
<li>Creating new docker container for each client: <code>ttyd docker run -it --rm ubuntu</code>.</li>
</ul>
<h1>Credits</h1>
<ul>
<li><a href="https://github.com/yudai/gotty">GoTTY</a>: ttyd is a port of GoTTY to <code>C</code> language with many improvements.</li>
<li><a href="https://libwebsockets.org">Libwebsockets</a>: is used to build the websocket server.</li>
<li><a href="https://github.com/sourcelair/xterm.js">Xterm.js</a>: is used to run the terminal emulator on the web, <a href="https://chromium.googlesource.com/apps/libapps/+/HEAD/hterm">hterm</a> is used previously.</li>
<li><a href="https://github.com/krishnasrinivas/wetty">Wetty</a>: <a href="https://nodejs.org">Node</a> based web terminal (SSH/login)</li>
<li><a href="https://github.com/yudai/gotty">GoTTY</a>: <a href="https://golang.org">Go</a> based web terminal</li>
</ul>
</div>
<script src="./prism.js" async></script>