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:

Ubuntu (12.04 LTS) or Debian (testing/unstable): sudo apt-get install mosh
Gentoo: emerge net-misc/mosh
Arch Linux: packer -S mobile-shell-git
FreeBSD: portmaster net/mosh
Mac OS X: mosh-1.1.3-2.pkg
Sources: mosh-1.1.3.tar.gz

Project’s website

P.S. It’s better that combination of SSH and GNU Screen.

Mosh screenshot

 

18 Comments

 

  1. April 13, 2012  1:44 am by Mick Reply

    I'm all for using converting to better tools, but ssh is still unmatched for port forwarding, X forwarding, sshfs, sftp. And don't forget rsync over ssh!

  2. April 13, 2012  2:47 am by Lars Noldan Reply

    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. :)

    • June 3, 2012  9:30 pm by Ex Reply

      It won't be default on every system until there is a freely licensed version of mosh.

      • January 1, 2013  12:11 am by Stephane Reply

        Mosh is un GNU, therefor, it's Free.

  3. Pingback : LXer: Why Mosh is better than SSH? | Build Future Repository

  4. April 13, 2012  5:47 pm by D Reply

    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.

    • June 3, 2012  1:14 am by DJ Reply

      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.

  5. April 13, 2012  6:06 pm by Shane Reply

    Screen can accomplish all of the things mentioned in the article.

    • June 3, 2012  9:37 pm by Ex Reply

      so does tmux, but tmux does more ;)

    • July 11, 2012  7:02 pm by Fabian Reply

      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...

  6. Pingback : Links 13/4/2012: Android on the Wrist, $35 Android ICS Tablet | Techrights

  7. Pingback : Why Mosh is better than SSH? - LinuxOS Pro - Linux News

  8. April 20, 2012  12:49 pm by Chris Reply

    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.

  9. Pingback : Émission #12 du 19 avril 2012 – Windows TV 8 bidule patate machin

  10. May 3, 2012  4:35 am by Tom Reply

    It not as good as ssh yet, for instance try to connect to a ssh server running on a non-standard port number you will have problems, they say they will fix it tho.

  11. Pingback : Network lesson: Virtual IP and Private VLAN « Summer Peppermint

  12. August 5, 2012  7:00 am by Pmlinux Reply

    No specific ports to listen to?
    No root rights needed to use Mosh?
    Keeps session after loosing connection?
    IP changes you stay logged in?

    Here let me just advertise that I want my system taken over by anyone who wants to hack me...

    Stupid software for stupid server administrators

  13. November 13, 2012  3:07 pm by Camilo Aguilar Reply

    UTF-8 a disadvantage? I totally disagree

Leave a reply

 

Your email address will not be published.