TranslateProject/sources/tech/20171128 tmate – Instantly Share Your Terminal Session To Anyone In Seconds.md

187 lines
6.1 KiB
Markdown
Raw Normal View History

2017-11-29 18:44:30 +08:00
translating by darksun
2017-11-29 17:35:54 +08:00
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/)
2017-11-29 17:35:54 +08:00
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.
2017-11-29 17:35:54 +08:00
### 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.
2017-11-29 17:35:54 +08:00
### 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
2017-11-29 17:35:54 +08:00
### 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.
2017-11-29 17:35:54 +08:00
```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.
2017-11-29 17:35:54 +08:00
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.
2017-11-29 17:35:54 +08:00
```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
```
2017-11-29 17:35:54 +08:00
Also, you can install tmate package from distribution official repository.
2017-11-29 17:35:54 +08:00
```shell
$ sudo apt-get install tmate
```
2017-11-29 17:35:54 +08:00
For **`Fedora`**, use [DNF Command](https://www.2daygeek.com/dnf-command-examples-manage-packages-fedora-system/)
to install tmate.
2017-11-29 17:35:54 +08:00
```shell
$ sudo dnf install tmate
```
2017-11-29 17:35:54 +08:00
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.
2017-11-29 17:35:54 +08:00
```shell
$ yaourt -S tmate
```
or
```shell
$ packer -S tmate
```
2017-11-29 17:35:54 +08:00
For **`openSUSE`**, use [Zypper Command](https://www.2daygeek.com/zypper-command-examples-manage-packages-opensuse-system/)
to install tmate.
2017-11-29 17:35:54 +08:00
```shell
$ sudo zypper in tmate
```
2017-11-29 17:35:54 +08:00
### 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.
2017-11-29 17:35:54 +08:00
```shell
$ tmate
```
2017-11-29 17:35:54 +08:00
[](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.
2017-11-29 17:35:54 +08:00
```shell
$ tmate show-messages
```
The tmate show-messages command allows you to see tmate's log messages,
including the ssh connection string.\
2017-11-29 17:35:54 +08:00
[](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?
2017-11-29 17:35:54 +08:00
### 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.
2017-11-29 17:35:54 +08:00
```shell
$ ssh session: ssh [email protected]
```
2017-11-29 17:35:54 +08:00
[](https://www.2daygeek.com/wp-content/uploads/2017/11/tmate-instantly-share-your-terminal-session-to-anyone-in-seconds-4.png)
2017-11-29 17:35:54 +08:00
### 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.\
2017-11-29 17:35:54 +08:00
[](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.
2017-11-29 17:35:54 +08:00
```
[Source System Output]
[exited]
2017-11-29 17:35:54 +08:00
[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/
2017-11-29 17:35:54 +08:00
作者:[ Magesh Maruthamuthu ][a]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出