Want to share your terminal with other users over a secure network? tmate is your friend for sharing SSH sessions. tmate is a terminal multiplexer with instant terminal exchange, that is, it allows you to use a terminal session with multiple trusted users. This is similar to the concept of multicast. All recipients access the terminal session over an SSH connection.
tmate is actually a fork of Tmux, a popular multiplexer terminal, allowing multiple programs to be used in a single terminal. This gives you an IDE experience in a terminal window.
How tmate lets you exchange terminals!
First, establish an SSH (secure shell) connection to the tmate.io site, which acts as a server on the Internet. Once the connection is established, a random SSH URL token is generated for each session. The ssh URL will appear at the bottom of your terminal session. The terminal is now ready for sharing.
Trusted teammates can access your terminal session through the URL ID and can use it as long as the connection is active. In my opinion, the best tmate application is helping with group projects, or debugging a project by a development team, or technical support on a remote network.
How to install tmate on Linux
tmate is a popular program, so it is available in the default repositories of most Linux distributions. All you have to do is use the Linux distribution’s package manager and install it.
We will provide some examples for your comfort.
sudo apt install tmate
for Fedora you can use this command:
sudo dnf install tmate
tmate is available in the AUR, so you can use your favorite AUR helper on Arch Linux:
yaourt -S tmate
On openSUSE, you can install zypper in tmate.
sudo zypper in tmate
How to share a terminal with tmate
Let’s see how to use tmate and exchange a terminal session with others.
Step 1: Create SSH Key Pair
To use tmate, we need to create an SSH key pair. Tmate first establishes a secure SSH connection from the host machine to the tmate.io site using this SSH key pair.
In addition, authentication of all client computers that try to connect to the host terminal is also done by the tmate.io server through the same ssh keys. Therefore, each system must have its own SSH key.
Use this command to create ssh key:
ssh-keygen -t rsa
Step 2: Using tmate on the host system
On the system where the terminal session will be used, open a terminal and enter the command “tmate” in your terminal.
The tmate sessions screen looks like this:
You would notice that after a few seconds the SSH session ID will disappear. You need this session ID so others can view your session.
To find the tmate sesson id, use the following command:
Get tmate SSH session id
Step 3: Access the tmate session
Share your SSH session ID with your trusted teammates and they can access your terminal using this command in their own terminal.
For example, in our case, it will be:
By default, tmate allows read / write access to the shared terminal session. This means that anyone connected to your session can execute commands in your terminal.
If you don’t want that, you can share the read-only session ID. If you look at the output of the show-messages command, you will notice that there are several session IDs. There you can find the read-only session ID.
Not only with SSH, you can share your terminal via a web url as well. You can get the URL of the web session in the show-messages output (as shown in the picture above).
Step 4: Ending the tmate session
Use the “exit” command to exit the tmate session.
Do you like tmux?
Since tmate is based on tmux, you can use all tmux commands in tmate terminal sessions. This is very useful for Linux and power users.
We hope you enjoyed this short article on a shared terminal using tmate. What is your experience with him. Share with us.