tmate is a clone of tmux (terminal multiplexer) that provides a secure, instant and easy-to-use terminal sharing solution over an SSH connection. It is built on top of tmux; you can run both terminal emulators on the same system. You can either use the official servers at tmate.io or host your own tmate server.
The following figure shows a simplified architecture diagram with the different components of the tmate (obtained from the project website).
How Tmate Works?
When launching Tmate, it will first establish an ssh connection to tmate.io server in the background through libssh. Once the connection is established, a 150 bits session token is generated for each session. Trusted users can use this generated token to access terminal session.
How to Install Tmate in Linux
Tmate is available to install from the default repositories of most Linux distributions using package manager as shown.
In Debian and Ubuntu-based Linux distributions, use the following PPA to 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
On Fedora distribution, use the following dnf command.
$ sudo dnf install tmate
On Arch Linux, you can install it from AUR as shown.
$ yaourt -S tmate
In openSUSE, you can use zypper command to install it.
$ sudo zypper in tmate
On Gento, you can use emerge to install it.
$ sudo emerge tmate
On other Linux distributions such as CentOS and RHEL, you can download sources from https://github.com/nviennot/tmate and compile and install with the following commands.
$ ./autogen.sh $ ./configure $ make $ sudo make install
How to Share Your Terminal Using Tmate
Once you have installed tmate, it uses both ~/.tmux.conf and ~/.tmate.conf configuration files. Everyone you share your terminal with, will be using your tmux config and your key bindings. The terminal is forced to 256 colors and UTF-8, so you don’t need to pass -2 as you may be used to do with tmux.
To launch tmate, run the following command, which makes the program to establish an ssh connection to tmate.io (or your own server) in the background through libssh.
Then you can share the ssh session connection parameters using generated token ID (for example: [email protected] in this case) with your mates so that they can access your terminal.
To access your terminal, your friend/colleagues needs to run the following ssh command in their terminal.
$ ssh 7sm[email protected]
To show tmate’s log messages, including the ssh connection string, run:
$ tmate show-messages
tmate also allows you to share a read-only view of your terminal. The read-only connection string can be retrieved with tmate show-messages as shown in the above screenshot.
To terminate the program, run the exit command.
For more information on how tmate works, how to run it as a daemon and host your own tmate server, go to the project website: https://tmate.io/.
Tmate is a fork of tmux that provides a secure, instant terminal sharing solution. In this article, we have shown how to install and use tmate in Linux and use it to share your terminal with your mates. Feel free to share your thoughts with us via the feedback form below.