3 minute read

As usual, links before everything

Overview

Want to do pair programming with your buddies over the net? Do you like tmux?

Enter tmate.

Key points

Briefly,

  1. tmate is a fork of tmux - this means that tmate is also a terminal multiplexer and we can reuse our favourite .tmux.conf and feel very much at home.
  2. Once a tmate session has been created, others can ssh connect to the session and do live pair programming in the terminal at the same time. There’s also an option for READ only sharing.
  3. tmate session can be used for remote access purposes as well.
  4. By default, we get random ephemeral connection string like ssh vbBK63dtemNN2ppDUqSvYNqbD@nyc1.tmate.io. It is possible to “name” the session and make the connection string deterministic and stable across restarts. Check out the docs for more info.
  5. But what if I want to prevent strangers from joining my session?
    Easy! Pass in an authorized_keys file containing authorized public keys we want to allow connecting to the session.
  6. Want to go super secure? Go host your own tmate servers!

TLDR? tmate is basically a reverse ssh tunnel accessible from anywhere.

Installation

I recommend checking out installation guide at https://tmate.io/#installation.

For me I used the following commands

▶ curl -Ls https://github.com/tmate-io/tmate/releases/download/2.4.0/tmate-2.4.0-static-linux-amd64.tar.xz | tar xf - -C /tmp -Jsudo mv /tmp/tmate-2.4.0-static-linux-amd64/tmate /usr/local/bin
▶ tmate -V
tmate 2.4.0

Usage

  • Start a tmate session
    ▶ tmate
    
  • Start a tmate session, allowing only authorized SSH clients to connect
    tmate -a authorized_keys
    

    Where authorized_keys contains public keys that are allowed to connect

  • Grab ssh connection string within tmate session
    ▶ tmate show-messages
    Mon Jan 24 17:57:01 2022 [tmate] Connecting to ssh.tmate.io...
    Mon Jan 24 17:57:02 2022 [tmate] Note: clear your terminal before sharing readonly access
    Mon Jan 24 17:57:02 2022 [tmate] web session read only: https://tmate.io/t/ro-tnLSDQsQD5W9SyqXJB3EaUAWQ
    Mon Jan 24 17:57:02 2022 [tmate] ssh session read only: ssh ro-tnLSDQsQD5W9SyqXJB3EaUAWQ@sfo2.tmate.io
    Mon Jan 24 17:57:02 2022 [tmate] web session: https://tmate.io/t/sn6U6B4QAEehNAUznSu8Q2kSg
    Mon Jan 24 17:57:02 2022 [tmate] ssh session: ssh sn6U6B4QAEehNAUznSu8Q2kSg@sfo2.tmate.io
    
  • On client device, connect to the session via ssh / web (https).
    For example, using the connection strings above
    ssh ro-tnLSDQsQD5W9SyqXJB3EaUAWQ@sfo2.tmate.io # Read only
    ssh sn6U6B4QAEehNAUznSu8Q2kSg@sfo2.tmate.io
    

Leave a comment