Emergency shell access with tmate
Over Your Shoulder

© Lead Image © Cathy Yeulet, 123RF.com
Tmate lets you access the shell session of a remote computer – even through a router.
Your parents or friends have replaced an unmanageable Windows installation with an easy-to-use Linux variant, and they have designated you as their remote admin. To access the system from afar, you resort to a GUI-based tool such as TeamViewer or AnyDesk. All is well until the graphical user interface (GUI) for the computer you need to access breaks. Suddenly, your GUI-based remote access tool won't work anymore, because you don't have access to an X server.
Tmate [1], which stands for "team mate," offers a convenient solution for remote access in situations when you can't depend on the graphical tools. This fork of the popular tmux [2] terminal multiplexer has significantly more functions than the original. Tmux is functionally similar to Screen [3] in some ways. You can use tmate to create and manage remote virtual sessions within a terminal or terminal emulator.
Self Hosted
Tmate is not only suitable for external help, but also lets developers collaborate on software. Technically, the tool uses Secure Shell (SSH) to establish a secure connection to the tmate.io server, which is under the control of the tmate developers.
Alternatively, you can run tmate on your own server. The resource requirements are kept within such narrow limits that a recent Raspberry Pi or a similarly equipped single-board computer is sufficient. The machine only generates an SSH ID and some URLs for different types of sessions – SSH or web sessions in read-only mode or with full access.
Installing tmate is easy, because the program is available from the package sources of all common distributions. For Arch Linux, use the AUR user archive; for Debian and its derivatives including Ubuntu, just type:
sudo apt install tmate
On Fedora, this translates to:
sudo dnf install tmate
Creating Keys
After the installation, which occupies only a few kilobytes on your disk, you need to create a key pair for SSH (if it does not already exist). As shown in Figure 1, this is done by typing:
ssh-keygen -t rsa -b 4096

Answer the individual prompts by pressing the Enter key. You can assign a password for the key, but in our example this is not necessary for home use.
Tmate uses the RSA cryptographic procedure with a secure key length of 4096 bits. By default, the keys are located in the hidden .ssh/
directory in your home directory; tmate will now find them automatically when you use the tool. You need to generate these keys on each computer involved if a key pair does not already exist there.
When you open a connection, the program creates a 150-bit session token. It then launches a tmux server in a sandbox without a filesystem and user rights, but with its own namespace to isolate the server from other processes. To make this possible, the software opens all the files it needs for running the tmux server before they end up in the sandbox.
These measures are intended to limit the leverage of potential exploits targeting the tmux server. An attacker would not be able to access other sessions. The technical principles are explained in detail in a 10-page paper [4].
SSH ID or URL
After starting tmate as a user for the first time, a bar at the bottom of the terminal window shows a random SSH ID for establishing an SSH session in Read/Write mode (Figure 2). It is best to copy this line to the clipboard, because it disappears after a short time.

If you did not react fast enough, you can get the data including the other IDs or URLs back on the screen with the tmate show-messages
command. This command is also used for logging during a session (Figure 3).

While the SSH ID displayed at the start of tmate creates a read-write session in a terminal, tmate show-messages
also shows an ID for a terminal session that supports read-only access. In addition, the program provides two URLs that support the same procedure in the browser (Figure 4).
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
Direct Download
Read full article as PDF:
Price $2.95
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Find SysAdmin Jobs
News
-
Kubuntu Focus Announces XE Gen 2 Linux Laptop
Another Kubuntu-based laptop has arrived to be your next ultra-portable powerhouse with a Linux heart.
-
MNT Seeks Financial Backing for New Seven-Inch Linux Laptop
MNT Pocket Reform is a tiny laptop that is modular, upgradable, recyclable, reusable, and ships with Debian Linux.
-
Ubuntu Flatpak Remix Adds Flatpak Support Preinstalled
If you're looking for a version of Ubuntu that includes Flatpak support out of the box, there's one clear option.
-
Gnome 44 Release Candidate Now Available
The Gnome 44 release candidate has officially arrived and adds a few changes into the mix.
-
Flathub Vying to Become the Standard Linux App Store
If the Flathub team has any say in the matter, their product will become the default tool for installing Linux apps in 2023.
-
Debian 12 to Ship with KDE Plasma 5.27
The Debian development team has shifted to the latest version of KDE for their testing branch.
-
Planet Computers Launches ARM-based Linux Desktop PCs
The firm that originally released a line of mobile keyboards has taken a different direction and has developed a new line of out-of-the-box mini Linux desktop computers.
-
Ubuntu No Longer Shipping with Flatpak
In a move that probably won’t come as a shock to many, Ubuntu and all of its official spins will no longer ship with Flatpak installed.
-
openSUSE Leap 15.5 Beta Now Available
The final version of the Leap 15 series of openSUSE is available for beta testing and offers only new software versions.
-
Linux Kernel 6.2 Released with New Hardware Support
Find out what's new in the most recent release from Linus Torvalds and the Linux kernel team.