What could be better than SSH? Three tools to consider

Image for post
Image for post

SSH is awesome. It lets you securely connect to remote computers and act like you’re on a local computer. It’s so common it’s even a verb:

“ssh into the server and restart it”

But it has some downsides:

It turns out something could be better than SSH if it solved these problems, and in fact, some tools do exist that augment SSH. They are, in no particular order, tmux, mosh, and Eternal Terminal.

Eternal Terminal

Image for post
Image for post

ET is the most ssh-like of the three. You can think of it like a drop-in replacement for ssh that reconnects automatically. Imagine: you connect to a remote machine, travel across the world reconnecting to 5 different WiFi networks, yet you’ve maintained your initial remote session!

You can run it like this:

et hostname

Mosh — the “mobile shell”

Image for post
Image for post

Mosh is similar to ET in that it persistently keeps you connected to a remote machine, but it does it in a very different way. Instead of forwarding every single thing from the remote machine to your machine like SSH and ET, it efficiently forwards you only the latest snapshot of the terminal.

It uses SSH to establish the initial connection, but then switches over to UDP and something called State Synchronization Protocol. This has pros and cons.

Pros:

Cons:

You can run it like this:

mosh hostname

tmux — the “terminal multiplexer”

Image for post
a single terminal split vertically by tmux (source)

Unlike ET and mosh, it does not establish or maintain remote connections. So what does it do?

It is an enhancement to ssh, EternalTerminal, or mosh which lets you re-use a single connection in multiple terminals.

You can do this in two ways:

tmux

2. Or integrate with the terminal to open new “virtual” terminal windows. This is called “command mode”:

tmux -CC

Command mode integrates with your terminal, so when you go to open a new tab or window, it will actually ask you: should I reuse the connection with tmux, or should I open a new terminal like I normally do?

Image for post
Image for post
Prompt when running tmux command mode in iTerm2

tmux turns the terminal into “just another program”, so when you use it, you can also

It basically lets you split a single session into multiple sessions without having to establish or maintain multiple connections. It “multiplexes” a bunch of virtual sessions through a single connection in a way that’s totally transparent to you, the user.

tmux is kinda like vim. It’s powerful, but you have to bite the bullet and learn some annoying, unintuitive keystrokes.

So which is right for you?

Image for post
Image for post

Use SSH if you…

Use Eternal Terminal if you want everything SSH offers but also

Use Mosh if you…

Use tmux if you…

My Choice

I settled on EternalTerminal, and sometimes use tmux with it.

Links

Written by

Software engineer and open source developer https://github.com/cs01, https://twitter.com/grassfedcode

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store