Girish Mahajan (Editor)

Mosh (software)

Updated on
Edit
Like
Comment
Share on FacebookTweet on TwitterShare on LinkedInShare on Reddit
Original author(s)
  
Keith Winstein

Type
  
Utility software

Operating system
  
Unix-like systems

Mosh (software) httpsmoshorgmoshpng

Initial release
  
March 12, 2012; 5 years ago (2012-03-12)

Stable release
  
1.2.6 / August 12, 2016; 7 months ago (2016-08-12)

Repository
  
github.com/keithw/mosh.git

In computing, Mosh (mobile shell) is a tool used to connect from a client computer to a server over the Internet, to run a remote terminal. Mosh is similar to SSH, with additional features meant to improve usability for mobile users. The major features are:

Contents

  • Mosh maintains its session even when "roams" (when the client endpoint changes to different IP addresses), for example by moving to a different Wi-Fi network or when changing from Wi-Fi to 3G.
  • Mosh maintains the terminal session (not "connection" in the TCP-sense because Mosh uses UDP) even when a user loses their Internet connection or puts their client to "sleep." In comparison, SSH can lose its connection in such cases because TCP times out.
  • Mosh client attempts to be responsive to keyboard events (typing, erasing characters with the [Delete] key, and so on, without waiting for network lag. It uses an adaptive system that predicts whether the application running on the server will decide to echo the user's keystrokes or deletions.
  • The main drawbacks of mosh are additional prerequisites to the server and that it lacks some special features of SSH (such as connection forwarding).

    Design

    Mosh works at a different layer from SSH. Whereas SSH transmits a stream of bytes in each direction (from server to client or client to server) using TCP, Mosh runs a terminal emulator at the server to figure out what should be on the screen. The server then transmits this screen to the client at a varying frame rate, depending on the speed of the network. This allows Mosh to save on network traffic on slow or intermittent connections.

    Supported platforms

    Mosh is available for most Linux distributions, Mac OS X, FreeBSD, NetBSD, and OpenBSD, Android, Solaris, Cygwin, and as a Chrome App. The iOS program iSSH included an independent implementation of the Mosh protocol as an optional add-on, but it is no longer available on the Apple App Store.

    Roaming

    Mosh is built on the State-Synchronization Protocol (SSP), which supports single-packet roaming. After the client has switched to a new IP address, a single packet that successfully reaches the server is enough to "roam" the connection. The client does not need to know it has roamed. (The client may be using NAT and the NAT roamed instead.)

    Packet loss

    In the Mosh research paper, the creators tested SSP on a link with 29% packet loss, and found that SSP reduced the average response time by a factor of 50 (from 16.8 seconds to 0.33 seconds) compared with SSH, which uses TCP. A different study, by students at Stanford University, found that SSP reduced the average response time by a factor of 30 (from 5.9 seconds to 0.19 seconds).

    Local echo

    According to mosh's developers, the program was found to be able to predict and immediately display 70% of user keystrokes, reducing the median response time to a keystroke to less than 5 milliseconds (masking the latency of the network). A different study, by students at Stanford University, found that Mosh was able to quickly echo 55% of user keystrokes

    Drawbacks

    Compared to the more popular SSH, mosh has the following drawbacks:

    Prerequisites on the server

    The major drawback of mosh is that it requires the server to fulfill additional prerequisites which are not needed by ssh itself. Due to its design, mosh needs the server to allow direct connections via UDP. Servers not fulfilling these prerequisites cannot be used by mosh. Examples of such systems include servers behind firewalls which restrict connections to the ssh-port via TCP. Also problematic are servers which are only indirectly reachable. The latter is usually accommodated by ssh via the 'ProxyCommand' option, but this is not supported by mosh.

    One port per connection

    By default, the server tries to allocate the first free UDP port in the range 60000-61000, per connection. This dynamic port allocation is considered an extra burden and risk for firewall maintenance. A significant part of the firewall-filtering happens through connection tracking, so called stateful filtering, this is based on the SYN/ACK flags in TCP segments, UDP packets don't have such flags.
    Mitigation:

    1. The UDP port on the server can be set per mosh connection, so that only a limited number of ports need to be opened
    2. Deep packet inspection firewalls and Application firewalls can handle this better by looking at content of the packet and associate it to the initial connection.

    No IPv6 roaming support

    Mosh 1.2.5 can only support non-roaming IPv6 connections. The use of the -6 option is necessary. There exists an experimental, multipath capable version of Mosh that supports IPv6 and dynamically switching between IPv4 and IPv6.

    Output drops and lack of terminal scrollback

    Scrollback is not supported in the current release of mosh, and when using it in a terminal emulator with scrollbars they disappear, but is planned for the 1.3 release. This functionality is trade-off for garbage cleaning, as binary output is wiped away. One way to mitigate this currently is by using mosh in combination with a terminal multiplexer like screen or tmux.

    Lack of ssh-agent forwarding

    SSH-agent forwarding is not currently supported.

    Lack of X11 forwarding

    X11 Forwarding is not yet supported.

    References

    Mosh (software) Wikipedia