Merge pull request #6388 from lujun9972/translating-20171128_tmate_–_Instantly_Share_Your_Terminal_Session_To_Anyone_In_Seconds.md

Translating 20171128 tmate – instantly share your terminal session to anyone in seconds.md
This commit is contained in:
Xingyu.Wang 2017-11-30 08:13:52 +08:00 committed by GitHub
commit ff71959525
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 156 additions and 186 deletions

View File

@ -1,186 +0,0 @@
translating by darksun
tmate -- Instantly Share Your Terminal Session To Anyone In Seconds
=================
A while ago, we wrote about
[teleconsole](https://www.2daygeek.com/teleconsole-share-terminal-session-instantly-to-anyone-in-seconds/)
which is used to share terminal instantly to anyone (whoever you trusting). Today also we are going to discuss about same kind of
application called tmate.
Why you want tmate application? this will help you to get help from your
friends when you need.
### What Is tmate?
[tmate](https://tmate.io/) stands for teammates, it's a fork of tmux,
and uses the same configurations such as keybindings, color schemes etc.
It's a terminal multiplexer with instant terminal sharing. it enables a
number of terminals to be created, accessed, and controlled from a
single screen, that can be shared with another mates.
You can detach the session by leaving the job running in background and
re-attach the session when you want to view the status. tmate provides
an instant pairing solution, allowing you to share a terminal with one
or several teammates.
A status line at the bottom of the screen shows information on the
current session, such as ssh command to share with your mate.
### How tmate works?
- When launching tmate, an ssh connection is established to tmate.io
(backend servers maintained by tmate developers) in the background
through libssh.
- The server (tmate.io) ssh key signatures are verified during the DH
exchange.
- The client is authenticated with local ssh keys.
- Once connection is established, a 150 bits (non guessable random
characters) session token is generated by local tmux server.
- teammates can connect to tmate.io using the SSH session ID provided
by user
### Prerequisites for tmate
Generate SSH key as a prerequisites since tmate.io server authenticate
client machine through local ssh keys. Make a note, every system should
have SSH key.
```shell
$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/magi/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/magi/.ssh/id_rsa.
Your public key has been saved in /home/magi/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:3ima5FuwKbWyyyNrlR/DeBucoyRfdOtlUmb5D214NC8 [email protected]
The key's randomart image is:
+---[RSA 2048]----+
| |
| |
| . |
| . . = o |
| *ooS= . + o |
| . [email protected]*o.o.+ E .|
| =o==B++o = . |
| o.+*o+.. . |
| ..o+o=. |
+----[SHA256]-----+
```
### How to Install tmate
tmate is available in few of the distribution official repository that
can be installed through package manager.
For **`Debian/Ubuntu`**, use [APT-GET Command](https://www.2daygeek.com/apt-get-apt-cache-command-examples-manage-packages-debian-ubuntu-systems/)
or [APT Command](https://www.2daygeek.com/apt-command-examples-manage-packages-debian-ubuntu-systems/)to install tmate.
```shell
$ sudo apt-get install software-properties-common
$ sudo add-apt-repository ppa:tmate.io/archive
$ sudo apt-get update
$ sudo apt-get install tmate
```
Also, you can install tmate package from distribution official repository.
```shell
$ sudo apt-get install tmate
```
For **`Fedora`**, use [DNF Command](https://www.2daygeek.com/dnf-command-examples-manage-packages-fedora-system/)
to install tmate.
```shell
$ sudo dnf install tmate
```
For **`Arch Linux`** based systems, use []()[Yaourt Command](https://www.2daygeek.com/install-yaourt-aur-helper-on-arch-linux/)
or []()[Packer Command](https://www.2daygeek.com/install-packer-aur-helper-on-arch-linux/)
to install tmate from AUR repository.
```shell
$ yaourt -S tmate
```
or
```shell
$ packer -S tmate
```
For **`openSUSE`**, use [Zypper Command](https://www.2daygeek.com/zypper-command-examples-manage-packages-opensuse-system/)
to install tmate.
```shell
$ sudo zypper in tmate
```
### How To Use tmate
After successfully installed, open your terminal and fire the following
command which will open the new session for you and in the bottom of the
screen you can able to see the SSH session ID.
```shell
$ tmate
```
[](https://www.2daygeek.com/wp-content/uploads/2017/11/tmate-instantly-share-your-terminal-session-to-anyone-in-seconds-1.png)
Make a note, the SSH session ID will disappear after a few seconds, so
don't worry you can get those details using following command.
```shell
$ tmate show-messages
```
The tmate show-messages command allows you to see tmate's log messages,
including the ssh connection string.\
[](https://www.2daygeek.com/wp-content/uploads/2017/11/tmate-instantly-share-your-terminal-session-to-anyone-in-seconds-2.png)
Now, share your SSH session ID to your friends or coworkers and allow
them to view the terminal session. Not only SSH session ID,
alternatively you can share web URL as well, also you can share either
read only sessions or read-write sessions?
### How to connect session through SSH
Just run the SSH session ID which you got from your friend on terminal.
It's like similar to below.
```shell
$ ssh session: ssh [email protected]
```
[](https://www.2daygeek.com/wp-content/uploads/2017/11/tmate-instantly-share-your-terminal-session-to-anyone-in-seconds-4.png)
### How to connect session through Web URL
Open the browser and access the URL which you got from your friend. It's
like similar to below.\
[](https://www.2daygeek.com/wp-content/uploads/2017/11/tmate-instantly-share-your-terminal-session-to-anyone-in-seconds-3.png)
Just type `exit` to exit from the session.
```
[Source System Output]
[exited]
[Remote System Output]
[server exited]
Connection to sg2.tmate.io closed by remote host.
Connection to sg2.tmate.io closed.
```
--------------------------------------------------------------------------------
via: https://www.2daygeek.com/tmate-instantly-share-your-terminal-session-to-anyone-in-seconds/
作者:[ Magesh Maruthamuthu ][a]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出

View File

@ -0,0 +1,156 @@
tmate -- 秒级分享你的终端会话
=================
不久前,我们写过一篇关于 [teleconsole](https://www.2daygeek.com/teleconsole-share-terminal-session-instantly-to-anyone-in-seconds/) 的介绍,该工具可用于快速分享终端给任何人(任何你信任的人)。今天我们要聊一聊另一款类似的应用,名叫 `tmate`
`tmate` 有什么用?它可以让你在需要帮助时向你的朋友们求助。
### 什么是 tmate
[tmate](https://tmate.io/) 的意思是 `teammates`,它是 tmux 的一个分支,并且使用相同的配置信息(例如快捷键配置,配色方案等)。
它是一个终端多路复用器,同时具有即时分享终端的能力。它允许在单个屏幕中创建并操控多个终端,同时这些终端还能与其他同事分享。
你可以分离会话,让作业在后台运行,然后在想要查看状态时重新连接会话. `tmate` 提供了一个即时配对的方案,让你可以与一个或多个队友共享一个终端。
在屏幕的地步有一个状态栏,显示了当前会话的一些诸如 ssh 命令之类的共享信息。
### tmate 是怎么工作的?
- 运行 `tmate` 时,会通过 `libssh` 在后台创建一个连接到 tmate.io (由 tmate 开发者维护的后台服务器)的ssh 连接。
- 服务器 (tmate.io) 的 ssh 密钥前面通过 DH 交换进行校验。
- 客户端通过本地 ssh 密钥进行认证。
- 连接创建后,本地 tmux 服务器会生成一个 150 位(不可猜测的随机字符)会话令牌。
- 队友能通过用户提供的 SSH 会话 ID 连接到 tmate.io。
### 使用 tmate 的必备条件
由于 `tmate.io` 服务器需要通过本地 ssh 密钥来认证客户机,因此其中一个必备条件就是生成 SSH 密钥 key。
记住,每个系统都要有自己的 SSH 密钥。
```shell
$ ssh-keygen -t rsa
Generating public/private rsa key pair。
Enter file in which to save the key (/home/magi/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/magi/.ssh/id_rsa。
Your public key has been saved in /home/magi/.ssh/id_rsa.pub。
The key fingerprint is:
SHA256:3ima5FuwKbWyyyNrlR/DeBucoyRfdOtlUmb5D214NC8 [email protected]
The key's randomart image is:
+---[RSA 2048]----+
| |
| |
| . |
| . . = o |
| *ooS= 。 o |
| . [email protected]*o.o.+ E .|
| =o==B++o = . |
| o.+*o+.. . |
| ..o+o=. |
+----[SHA256]-----+
```
### 如何安装 tmate
`tmate` 已经包含在某些发行版的官方仓库中,可以通过包管理器来安装。
对于 **`Debian/Ubuntu`**,可以使用 [APT-GET 命令](https://www.2daygeek.com/apt-get-apt-cache-command-examples-manage-packages-debian-ubuntu-systems/)
或者 [APT 命令](https://www.2daygeek.com/apt-command-examples-manage-packages-debian-ubuntu-systems/)to 来安装。
```shell
$ sudo apt-get install software-properties-common
$ sudo add-apt-repository ppa:tmate.io/archive
$ sudo apt-get update
$ sudo apt-get install tmate
```
你也可以从官方仓库中安装 tmate。
```shell
$ sudo apt-get install tmate
```
对于 **`Fedora`**,使用 [DNF 命令](https://www.2daygeek.com/dnf-command-examples-manage-packages-fedora-system/) 来安装。
```shell
$ sudo dnf install tmate
```
对于基于 **`Arch Linux`** 的系统,使用 []()[Yaourt 命令](https://www.2daygeek.com/install-yaourt-aur-helper-on-arch-linux/)
或 []()[Packer 命令](https://www.2daygeek.com/install-packer-aur-helper-on-arch-linux/) 来从 AUR 仓库中安装。
```shell
$ yaourt -S tmate
```
```shell
$ packer -S tmate
```
对于 **`openSUSE`**,使用 [Zypper 命令](https://www.2daygeek.com/zypper-command-examples-manage-packages-opensuse-system/) 来安装。
```shell
$ sudo zypper in tmate
```
### 如何使用 tmate
成功安装后,打开终端然后输入下面命令,就会打开一个新的会话,在屏幕底部,你能看到 SSH 会话的 ID。
```shell
$ tmate
```
[](https://www.2daygeek.com/wp-content/uploads/2017/11/tmate-instantly-share-your-terminal-session-to-anyone-in-seconds-1.png)
要注意的是SSH 会话 ID 会在几秒后消失,不过不要紧,你可以通过下面命令获取到这些详细信息。
```shell
$ tmate show-messages
```
`tmate``show-messages` 命令会显示 tmate 的 log 信息,其中包含了 ssh 连接内容。
[](https://www.2daygeek.com/wp-content/uploads/2017/11/tmate-instantly-share-your-terminal-session-to-anyone-in-seconds-2.png)
现在,分享你的 SSH 会话 ID 给你的朋友或同事从而允许他们观看终端会话. 除了 SSH 会话 ID 以外,你也可以分享 web URL。
另外你还可以选择分享的是只读会话还是可读写会话。
### 如何通过 SSH 连接会话
只需要在终端上运行你从朋友那得到的 SSH 终端 ID 就行了. 类似下面这样。
```shell
$ ssh session: ssh 3KuRj95sEZRHkpPtc2y6jcokP@sg2.tmate.io
```
[](https://www.2daygeek.com/wp-content/uploads/2017/11/tmate-instantly-share-your-terminal-session-to-anyone-in-seconds-4.png)
### 如何通过 Web URL 连接会话
打开浏览器然后访问朋友给你的 URL 就行了. 像下面这样。
[](https://www.2daygeek.com/wp-content/uploads/2017/11/tmate-instantly-share-your-terminal-session-to-anyone-in-seconds-3.png)
只需要输入 `exit` 就能退出会话了。
```
[Source System Output]
[exited]
[Remote System Output]
[server exited]
Connection to sg2.tmate.io closed by remote host。
Connection to sg2.tmate.io closed。
```
--------------------------------------------------------------------------------
via: https://www.2daygeek.com/tmate-instantly-share-your-terminal-session-to-anyone-in-seconds/
作者:[ Magesh Maruthamuthu ][a]
译者:[lujun9972](https://github.com/lujun9972)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出