tmate – Instantly Share Your Terminal Session To Anyone In Seconds
A while ago, we wrote about teleconsole 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 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.
$ 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.
$ 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.
$ sudo apt-get install tmate
Fedora, use DNF Command to install tmate.
$ sudo dnf install tmate
$ yaourt -S tmate or $ packer -S tmate
openSUSE, use Zypper Command to install tmate.
$ 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.
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.
$ tmate show-messages
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.
$ ssh session: ssh [email protected]
How to connect session through Web URL
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.