Hi! I'm Mai.
I'm a senior developer
@ Phase2 Technology
Robbie Holmes
robbiethegeek
Director of Engineering @ Phase2
And I’m going to share with you what Robbie Holmes, or as he’s known everywhere as robbiethegeek, shared with me when we were chatting about pair programming some time ago.
I’m certainly not a tmate expert but I thought it was pretty neat.
The Problem
So I’m sure many of you have experienced this type of problem before when developing.
Devs happily coding and working together on a team
Ok, so we have two devs on our team. Look at them, they are both happily coding away.
Hrm, we've got an issue
uh-oh, one of our Dev’s has an issue.
And then it’s time to escalate this trouble-shooting to a hangout, or whatever kind of meeting that allows screensharing.
It's so hard to read and troubleshoot.
At this point, you really just want to type it out yourself rather than dictating and squinting
tmate to the rescue!
What is tmate?
tmate is a fork of tmux. tmate and tmux can coexist on the same system, they do not conflict with each other.
tmate will give you the power of sharing your terminal!
What is tmux?
tmux is a terminal multiplexer
https://tmux.github.io/
https://pragprog.com/book/bhtmux/tmux
That means:
You can switch easily between several programs in a single terminal
Detach them and keep them running in the background
Reattach them to a different terminal
...and moar !
This is great if you have a script that runs for a long time and you want to run it in the background,
or if you want to switch between your database console, web server, and etc with minimal effort.
How to Use?
Once you have it installed, it's relatively simple to use. Since it's based on tmux, you can
use all tmux commands as well.
Sharing a Read/Write Session
You can share a read only terminal or allow the user to also have write access.
HTML5 Client
There is an HTML Client in progress...
However, the client has problems like the tmux key bindings don't work and there are some graphical bugs
Plus...the whole point is terminal sharing...so use a terminal!
Other benefits
Terminal Sharing also opens the door for...
Pair Programming!
Remote Pair Programming
Using tmate for remote pair pairing is straightforward
Grab a good headset with a microphone
Jump on Google Hangouts, Skype, etc
Run tmate
Share a read/write session with your partner
Edit with vim
Celebrate!
How to Install?
Mac OS X
You need to have Homebrew
installed as a prerequisite.
brew update && \
brew tap nviennot/tmate && \
brew install tmate
How to Install?
Ubuntu
Ubuntu 12.04 and up have published packages for tmate.
sudo apt-get install software-properties-common && \
sudo add-apt-repository ppa:nviennot/tmate && \
sudo apt-get update && \
sudo apt-get install tmate
How to Install?
From Source
Grab the sources from github: https://github.com/nviennot/tmate .
A few dependencies are required. The Ubuntu packages names are:
git-core build-essential pkg-config libtool libevent-dev libncurses-dev zlib1g-dev automake libssh-dev cmake ruby
./autogen.sh && \
./configure && \
make && \
make install
How does it work?
When launching tmate, an ssh connection is established to tmate.io (or your own server) in the background through libssh.
The client is authenticated with local ssh keys.
When a connection is established, a session token is generated, then a tmux server is spawned in a jail with no file system, with its own PID namespace to isolate the server from other processes, and no user privileges.
When your partner connects using the connection string, the tmux unix socket is looked up on the file system.
On lookup success, a tmux client is spawned and connected to the remote tmux server.
My connection goes thru tmate.io ???
My Shiz is secret...
You can host your own tmate server
Code: https://github.com/nviennot/tmate-slave
tmate server has some package dependencies. Once those are installed on the server, you can install tmate-slave with:
git clone https://github.com/nviennot/tmate-slave.git && cd tmate-slave
./create_keys.sh # This will generate SSH keys, remember the keys fingerprints.
./autogen.sh && ./configure && make
sudo ./tmate-slave
...Set up the ~/.tmate.conf file
...And start your server with the following command:
tmate-slave [-k keys_dir] [-l logfile] [-p port] [-h host] [-v]
Additional info on hosting your own tmate Server
Our scenario revisited...
Ok, back to when our dev was saying something wasn't working on his local dev environment.
You can still jump on a call but instead of sharing your screen, share your terminal instead!
Thank you!