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 similar kind of application called tmate.
Why you want tmate application? This will help you to get help from your friends whenever 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 | | . =.@*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.
Debian/Ubuntu, use APT-GET Command or APT Commandto install tmate.
$ 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
Arch Linux based systems, use Yaourt Command or Packer Command to install tmate from AUR repository.
$ 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
The tmate show-messages command allows you to see tmate’s log messages, including the ssh connection string.
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
Open the browser and access the URL which you got from your friend. It’s like similar to below.
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.