Tmate – Securely Share SSH Terminal Session with Linux Users

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).

tmate - Simplified Architecture Diagram

tmate – Simplified Architecture Diagram

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.

$ tmate 
Tmate Session

Tmate Session

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 [email protected]
Tmate Session Sharing with Friends

Tmate Session Sharing with Friends

To show tmate’s log messages, including the ssh connection string, run:

$ tmate show-messages
Tmate Log Messages

Tmate Log 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.

$ exit

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.

Best Affordable Linux and WordPress Services For Your Business
Outsource Your Linux and WordPress Project and Get it Promptly Completed Remotely and Delivered Online.

If You Appreciate What We Do Here On TecMint, You Should Consider:

  1. Stay Connected to: Twitter | Facebook | Google Plus
  2. Subscribe to our email updates: Sign Up Now
  3. Get your own self-hosted blog with a Free Domain at ($3.45/month).
  4. Become a Supporter - Make a contribution via PayPal
  5. Support us by purchasing our premium books in PDF format.
  6. Support us by taking our online Linux courses

We are thankful for your never ending support.

Aaron Kili

Aaron Kili is a Linux and F.O.S.S enthusiast, an upcoming Linux SysAdmin, web developer, and currently a content creator for TecMint who loves working with computers and strongly believes in sharing knowledge.

Your name can also be listed here. Got a tip? Submit it here to become an TecMint author.

RedHat RHCE and RHCSA Certification Book
Linux Foundation LFCS and LFCE Certification Preparation Guide

You may also like...

2 Responses

  1. DDS says:

    Good idea, but only if you host your own server.
    I would never trust my shell to anything that uses an internet service to work.

Got something to say? Join the discussion.

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.