How to use a remote shell over flaky connections without losing your nerves

Recently, I’ve stumbled upon the Mosh remote shell application, and since then I can’t stop talking about it! If you need to access your servers’ command line interface over slow, unreliable connections, you want to use the Mobile Shell.

As the website describes it, Mosh is a…

Remote terminal application that allows roaming, supports intermittent connectivity, and provides intelligent local echo and line editing of user keystrokes.

And – spoiler alert – it works so well that I’ve completely replaced ssh for mosh for accessing our many servers. SSH is still necessary, though, because the Mosh client first opens an SSH connection to the target server and then launches its server component there. After establishing an UDP connection between the client and server components, the SSH connection is dropped.

By using a new protocol called the State Synchronization Protocol (SSP) which is based on UDP, Mosh provides a shell connection that’s far more usable over slow and flaky connections than SSH, for example when using a 3G network from a train. It even survives reconnects that change the client’s IP address. I was really amazed when, on my first day with Mosh, all shell sessions I started in Starbucks simply resumed after I opened my laptop again in my homeoffice.

Local Echo is another great feature that makes working over unreliable connections far less annoying. While SSH doesn’t display your keystrokes until they have been sent back from the server, Mosh shows them immediately without requiring the roundtrip. That way, you can spot and correct typos without wait and finally hit the Enter key with all confidence. It may take some time until you see the effect of your command due to your slow connection, but at least typing it was no hassle at all. Whily typing, Mosh gives you visual feedback about the synchronization process by underlining those parts of the command line that have not yet been acknowledged by the server.

Of course, Mosh also uses encryption, so you don’t lose any security by switching from SSH to Mosh. Installation is easy, too, so don’t wait any more. Start moshing!

1 thought on “How to use a remote shell over flaky connections without losing your nerves”

Comments are closed.