Get your server issues fixed by our experts for a price starting at just 25 USD/Hour. Click here to register and open a ticket with us now!

Author Topic: Instantly Share Terminal Session With Other Linux Users  (Read 1780 times)

0 Members and 1 Guest are viewing this topic.

akhilt

  • Guest
Instantly Share Terminal Session With Other Linux Users
« on: August 05, 2018, 10:55:42 am »
Instantly Share Terminal Session With Other Linux Users


If you want to share the SSH session terminal with other users over a secure network, tmate is your friend.

tmate is a terminal multiplexer with instant terminal sharing i.e, it enables sharing your terminal session with a number of trusted users. It is similar to the concept of multicasting. All the recipients get to view the terminal session over an SSH connection.

tmate is actually a fork of Tmux, a popular terminal multiplexer that lets you use several programs in a single Terminal. It gives you an IDE kind of experience in the terminal window.

How tmate works

On starting Tmate, it will first establish SSH (secure shell) connection to tmate.io website 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 ID will be displayed at the bottom of your terminal session. Now the terminal is ready to be shared.

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, tmate’s best application is to assist in group projects, or to debug the project with a team of developers, or get technical support on the remote network.

How to install tmate in Linux

tmate is a popular program and hence it is available in the default repositories of most Linux distributions. All you have to do is to use your Linux distribution’s package manager and install it.

In Debian and Ubuntu-based Linux distributions, use this command:
Code: [Select]
sudo apt install tmate
For Fedora, you can use this command:
Code: [Select]
sudo dnf install tmate
tmate is available in AUR(Arch User Repository) so you can use your favorite AUR Helper in Arch Linux:
Code: [Select]
yaourt -S tmate
In openSUSE, you can zypper to install tmate.
Code: [Select]
sudo zypper in tmate
How to share terminal with tmate

Step 1: Generate SSH Key-Pair

To use tmate, we need to create an SSH key-pair. The Tmate program first establishes a secure SSH connection of host machine with tmate.io website using that SSH key pair.

Also, the authentication of every client machines that try to connect to host terminal is also made by tmate.io server through same ssh keys. Hence, every system should have their SSH key generated.

Use this command to generate ssh-key:
Code: [Select]
ssh-keygen -t rsa
Step 2: Use tmate on host system

On the system where the terminal session will be used, open a terminal and enter “tmate” command in your terminal.
Code: [Select]
tmate
In a few seconds, the SSH session ID will disappear. You need this session ID so that others can view your session.

To find the tmate sesson id, use the following command:
Code: [Select]
tmate show-messages
Step 3: Access tmate session

Share the SSH session ID with your trusted teammates and they can access your terminal using this command in their own terminal.
Code: [Select]
ssh <SSH_session_ID>
By default, tmate allows both read and write access to the shared terminal session. Which means that anyone connected to your session can run 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’ll notice there are several session IDs. You can find the read-only session id there.

Not only with SSH, you can share your terminal through web URL as well. You can get the web session URL in the show-messages output.

Step 4: End tmate session

Use “exit” command to exit the tmate session.
Code: [Select]
exit
Since tmate is based on tmux, you can use all tmux commands in tmate terminal sessions. This is very useful for Linux power users.

I hope you liked this quick article on sharing terminal with tmate.