Linux.com

Home Learn Linux Linux Tutorials Into the Mosh Pit: A Mobile Shell Replacement for SSH

Into the Mosh Pit: A Mobile Shell Replacement for SSH

SSH is a wonderful thing, but it doesn't deal very well with today's mobile workers. When dealing with iffy Wi-Fi connections, moving around from coffeeshop to home office, or just putting your laptop to sleep for a few minutes, you lose your SSH connection. If you need a persistent connection, take a look at Mosh.

Some tools already provide a kludgey way around dropped connections and workers who need mobility. Lots of us, for instance, use GNU Screen or Tmux to ensure that we can keep a shell session going if we need to drop our connection.

But that's, well, kludgey. It'd be better if you had a tool that could handle network problems and modern day computer usage with aplomb. And that tool appears to be Mosh.

What's Mosh?

Mosh is a terminal application that supports roaming, intermittent connectivity, and gets rid of the wait for a server reply when showing you your keystrokes.

When I say that Mosh is a "replacement" for SSH, that's sort of an exaggeration, though. Mosh actually uses SSH to make the connection, but then hands off to the remote mosh-server and runs over UDP.

Getting Mosh

If you look at the Mosh Website you'll see that the project is packaged for Debian, Ubuntu, Fedora, Arch, and even Mac OS X. If all of that doesn't help, Mosh is open source (GPLv3 or later) and you can grab the source and compile on your own.

It doesn't look like there's a Mosh package or installer for Windows, though. Sorry Windows users! You don't get the cool tools like the rest of the *nix using folks. If Mosh becomes more popular, though, I suspect someone will take the charge in creating a Windows client as well.

You need to install Mosh on the client and server that you're going to be using. This is the primary downside for Mosh over SSH at the moment. If you don't have admin privileges over a server you need to connect to, and you can't convince the admin you need Mosh, you're stuck with SSH – or installing the Mosh binary in your home directory.

I've been testing Mosh on a Linux Mint box connecting to an Ubuntu 10.04 system. It took, maybe, five minutes to get everything installed. You'll need to enable backports or a Personal Package Archive (PPA), but once that's done it's a simple as sudo apt-get install mosh.

Using Mosh

You might think that Mosh would be difficult to use. It's not. Instead of typing ssh servername ssh user@servername you just type mosh servername or mosh user@servername. In other words, the syntax is the same as if you'd used SSH.

As mentioned above, you may need to install the mosh-server binary yourself if your admin doesn't want to install the Mosh package. If that's the case, you'll need to specify the path to the Mosh server on the command line, like so:

mosh --server=/home/user/bin/mosh-server servername

Note that it's probably a good idea to at least mention to your admin that you'll be uploading Mosh and using it from your home directory. It's generally not recommended to install binaries on a system that you're not administering without the knowledge of the admin.

In some limited cases, you might run into problems with Mosh because it only supports UTF-8. See the FAQ on the Mosh site about UTF-8 support.

Note that Mosh doesn't support some advanced SSh features, like X11 connections, yet. According to the site, they are working on X11 forwarding and an Android client. (IPv6-only support is also coming, for the few folks who might have need of that.)

Simple, Useful, Awesome!

Mosh fits into the category of tools that (at least for me) just work. It promises to make life a bit easier for users who are "road warriors" and working from all over the place, as well as for users who have spotty Internet connections.

Kudos to the Mosh folks, it's a fantastic tool!

 

Comments

Subscribe to Comments Feed

Who we are ?

The Linux Foundation is a non-profit consortium dedicated to the growth of Linux.

More About the foundation...

Frequent Questions

Join / Linux Training / Board