Why Mosh is better than SSH?

Mosh (stands for Mobile Shell) is replacement of SSH for remote connections to Unix/Linux systems. It brings a few noticeable advantages over well known SSH connections. In brief, it’s faster and more responsive, especially on long delay and/or unreliable links.

Key benefits of Mosh

Stays connected if your IP is changed. Roaming feature of Mosh allows you to move between Internet connections and keep Mosh session online. For example, if your wifi connection changes IP you don’t need to reconnect.

Keeps session after loosing connection. For example, if you lost Internet connection for some time, or your laptop went offline due to exhausted battery – you’ll be able to pick up previously opened Mosh session easily.

No root rights needed to use Mosh. Unlike SSH Mosh server is not a daemon that needs to listen on specific port to accept incoming connections from clients. Mosh server and client are executables that could be run by ordinary user.

The same credentials for remote login. Mosh uses SSH for authorization so in order to open connection you need the same credentials as before.

Responsive Ctrl+C combination. Unlike SSH Mosh doesn’t fill up network buffers so even if you accidentally requested to output 100 MB file you’ll be able to hit Ctrl+C and stop it immediately.

Better for slow or lagged links. Have you ever tried to use SSH on satellite link where average RTT is 600 ms or more? Wish Mosh you don’t need to wait until server replies to see your typing. It works in CLI and such programs as vi or emacs so on it makes it possible to do the job slow connections more comfortably.

Well, there are some disadvantages too:

No IPv6 support.

UTF-8 only.

Mosh is available for all major Linux distributions, FreeBSD and Mac OS X systems:

Until MOSH is the default on EVERY unix like system, and has clients available for every major mobile device platform this tool is no more useful than a blender for logging into and managing systems. Technically Betamax was superior to VHS. You see where that got us. :)

Always nice to have options but as far as session recovery just use screen. Its tried, true, feature rich and independent of your connection method. OpenSSH is more than terminal access as was pointed out by Mick and the lack of port forwarding features alone makes these two tools entirely different breeds. There are various ssh clients out there that provide Local Echo functionality as well.

I use screen together with mosh. There's no rule that says you can't use both. GNU screen preserves your server state, and mosh performs automatic reconnection when your local connection dies or your local IP changes. Both features are very useful. I find mosh's automatic reconnection to be much less disruptive than (say) autossh, because the mosh protocol is stateless (unlike ssh over TCP).

I think you misunderstand the local echo feature in mosh. It's not a standard local echo feature that echoes back every single character you type. It echoes back characters which have not yet been acknowledged by the server due to laggy links, and reconciles the local buffer with the remote server once the server responds.

For those who say ssh is better because of port forwarding etc., no problem. You can use ssh and mosh at the same time. The comparison to VHS/Betamax is also inappropriate, because mosh can also coexist with ssh on the server side. A more proper comparison would be to a player that supports both VHS and Betamax at the same time.

screen does not. It preserves what you did in your login on the server, but it doesn't give you a persistent connection. It's comparing apples and bananas.

I have been using mosh + screen for a few weeks now and I am very happy. My DSL disconnects once every 24h, typically at 4am. Nowadays I don't even notice it, in the morning my mosh connections are open as always. With ssh I always had to reconnect, which was not a big pain, but a lot of little pains add up...

I am not sure how much of an advantage staying connected if your IP changes really is. I can see how it is a convenience; but, likewise, I can see how it opens up attack vectors that are just not present with the alternate behaviour Session management is not really a problem, with Screen or tmux.

I keep seeing this "no root" note for Mosh. Well, here is the deal. First of all, you will require root to have some sort of authentication service that can start the Mosh server as your user. Secondarily, not binding to reserved ports sounds nice, but you will quickly find firewalls on many servers will not allow these high-bound UDP ports. So, you need root to change the firewall rulesets. Note, I don't say you need the root account, I mean you need the root user to do these actions for you.

Also, of course Mosh uses the same credentials, as it uses SSH. The client and server of Mosh then use a pre-shared key, as far as I am aware. (That is to say, Mosh uses SSH to authenticate you remotely, and start a Mosh server process, that it then connects to. The authentication between the Mosh client and the Mosh server is using a pre-shared key.)

The other big issue that people are neglecting, is that the author of the tool clearly states that he wants cryptographic review of the implementation. I won't spread FUD, but I will say that I would prefer to wait until after then before I start using it for administration of important remote systems.

Related posts

In this post you will find set of password managers for Linux which provides secure storage for your passwords for sensitive data. If you still keep the passwords in plain text then you must consider one of available pas... →

HAProxy is open source proxy that can be used to enable high availability and load balancing for web applications. It was designed especially for high load projects so it is very fast and predictable, HAProxy is based on... →

Artem is systems engineer for more than 7 years and holds broad experience in Linux, Unix, Cisco systems administration. Feel free to get in touch with Artem Nosulchik via Google Plus, Twitter or Facebook.

Most Read This Week

LinuxScrew Recommends

Who’s behind LinuxScew?

My name is Artem Nosulchik, I'm part time blogger and full-time Linux sysadmin. In 2007 I started LinuxScrew to share my personal notes on anything related to Linux and Open Source on the whole and found this pretty interesting.