In
computing
Computing is any goal-oriented activity requiring, benefiting from, or creating computer, computing machinery. It includes the study and experimentation of algorithmic processes, and the development of both computer hardware, hardware and softw ...
, 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: the mobile shell"](_blank)
Retrieved on 28 March 2013. Mosh is similar
[Brockmeier, Joe]
"Into the Mosh Pit: A Mobile Shell Replacement for SSH"
, ''linux.com'', 10 April 2012. Retrieved on 28 March 2013. to
SSH, with additional features meant to improve usability for
mobile users. The major features are:
* Mosh maintains its session even when it "
roams" (when the client endpoint changes to different
IP addresses), for example by moving to a different
Wi-Fi
Wi-Fi () is a family of wireless network protocols based on the IEEE 802.11 family of standards, which are commonly used for Wireless LAN, local area networking of devices and Internet access, allowing nearby digital devices to exchange data by ...
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
Sleep is a state of reduced mental and physical activity in which consciousness is altered and certain Sensory nervous system, sensory activity is inhibited. During sleep, there is a marked decrease in muscle activity and interactions with th ...
". In comparison, SSH can lose its connection in such cases because
TCP times out.
[Cox, John]
"MIT researchers chart a new approach for mobile Internet protocols"
, ''Network World'', 6 July 2012. Retrieved on 28 March 2013.
* A Mosh client attempts to be responsive to keyboard events (typing, erasing characters with the 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
In audio signal processing and acoustics, an echo is a reflection of sound that arrives at the listener with a delay after the direct sound. The delay is directly proportional to the distance of the reflecting surface from the source and the lis ...
the user's keystrokes or deletions.
[Beckert, Axel]
"Mosh and AutoSSH: Remote shell tools that make your life easier on a slow or constantly morphing network"
''Linux Magazine'', November 2012.[Leyden, John]
"MIT's mind-reading Mosh pits itself against SSH daemons"
''The Register'', 13 April 2012. Retrieved on 28 March 2013.
The main
drawbacks of Mosh are additional prerequisites to the server, that it lacks some special features of SSH (such as connection forwarding) and the lack of a
native
Native may refer to:
People
* '' Jus sanguinis'', nationality by blood
* '' Jus soli'', nationality by location of birth
* Indigenous peoples, peoples with a set of specific rights based on their historical ties to a particular territory
** Nat ...
Windows
Windows is a Product lining, product line of Proprietary software, proprietary graphical user interface, graphical operating systems developed and marketed by Microsoft. It is grouped into families and subfamilies that cater to particular sec ...
client.
An alternative for Linux servers (that still require installation on the server) is to use
GNU Screen on top of a regular SSH connection.
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
A terminal emulator, or terminal application, is a computer program that emulates a video terminal within some other display architecture. Though typically synonymous with a shell or text terminal, the term ''terminal'' covers all remote term ...
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.
[Winstein, Keith]
"Mosh: An Interactive Remote Shell for Mobile Clients"
USENIX Annual Technical Conference 2012, Boston, Mass., 14 June 2012. This allows Mosh to save on network traffic on slow or intermittent connections.
Supported platforms
Mosh is available for most
Linux distribution
A Linux distribution, often abbreviated as distro, is an operating system that includes the Linux kernel for its kernel functionality. Although the name does not imply product distribution per se, a distro—if distributed on its own—is oft ...
s,
macOS
macOS, previously OS X and originally Mac OS X, is a Unix, Unix-based operating system developed and marketed by Apple Inc., Apple since 2001. It is the current operating system for Apple's Mac (computer), Mac computers. With ...
,
FreeBSD
FreeBSD is a free-software Unix-like operating system descended from the Berkeley Software Distribution (BSD). The first version was released in 1993 developed from 386BSD, one of the first fully functional and free Unix clones on affordable ...
,
NetBSD
NetBSD is a free and open-source Unix-like operating system based on the Berkeley Software Distribution (BSD). It was the first open-source BSD descendant officially released after 386BSD was fork (software development), forked. It continues to ...
, and
OpenBSD
OpenBSD is a security-focused operating system, security-focused, free software, Unix-like operating system based on the Berkeley Software Distribution (BSD). Theo de Raadt created OpenBSD in 1995 by fork (software development), forking NetBSD ...
,
Android,
Solaris
Solaris is the Latin word for sun.
It may refer to:
Arts and entertainment Literature, television and film
* ''Solaris'' (novel), a 1961 science fiction novel by Stanisław Lem
** ''Solaris'' (1968 film), directed by Boris Nirenburg
** ''Sol ...
,
Cygwin
Cygwin ( ) is a free and open-source Unix-like environment and command-line interface (CLI) for Microsoft Windows. The project also provides a software repository containing open-source packages. Cygwin allows source code for Unix-like operati ...
, and as a
Chrome App.
The iOS program Termius includes an independent implementation of the Mosh protocol.
Performance
Roaming
Mosh is built on the
State-Synchronization Protocol (SSP), which supports single-packet roaming.
[Winstein, Keith and Balakrishnan, Hari]
"Mosh: An Interactive Remote Shell for Mobile Clients (more detailed draft)"
Retrieved on 28 March 2013. 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 on a network with
network address translation
Network address translation (NAT) is a method of mapping an IP address space into another by modifying network address information in the IP header of packets while they are in transit across a traffic Router (computing), routing device. The te ...
(NAT) when the NAT router roams.)
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
Leland Stanford Junior University, commonly referred to as Stanford University, is a Private university, private research university in Stanford, California, United States. It was founded in 1885 by railroad magnate Leland Stanford (the eighth ...
, found that SSP reduced the average response time by a factor of 30 (from 5.9 seconds to 0.19 seconds).
[Nagaraj, Kanthi and McMilin, Emily]
"Mosh"
''Reproducing Network Research'', 14 March 2013. Retrieved on 28 March 2013.
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.
[Aljunied, Ahmed]
"Evaluation of Mosh 'Mobile Shell' Performance Results"
''Reproducing Network Research'', 13 March 2013. Retrieved on 28 March 2013.
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 60001–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:
# The UDP port on the server can be set per Mosh connection, so that only a limited number of ports need to be opened
#
Deep packet inspection firewalls and
application firewall
An application firewall is a form of firewall that controls input/output or system calls of an application or service. It operates by monitoring and blocking communications based on a configured policy, generally with predefined rule sets to c ...
s can handle this better by looking at content of the packet and associate it to the initial connection
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 a trade-off for garbage cleaning, as binary output is wiped away. One way to mitigate this is by using Mosh in combination with a terminal multiplexer like
screen or
tmux
tmux is an open-source terminal multiplexer for Unix-like operating systems. It allows multiple terminal sessions to be accessed simultaneously in a single window. It is useful for running more than one command-line program at the same time ...
.
Lack of ssh-agent forwarding
ssh-agent forwarding is not currently supported.
Lack of X11 forwarding
X11
The X Window System (X11, or simply X) is a windowing system for bitmap displays, common on Unix-like operating systems.
X originated as part of Project Athena at Massachusetts Institute of Technology (MIT) in 1984. The X protocol has been at ...
forwarding is not yet supported.
"Support X forwarding"
/ref>
See also
* Block-oriented terminal
A computer terminal is an electronic or electromechanical computer hardware, hardware device that can be used for entering data into, and transcribing data from, a computer or a computing system. Most early computers only had a front panel to ...
* Command-line interface
A command-line interface (CLI) is a means of interacting with software via command (computing), commands each formatted as a line of text. Command-line interfaces emerged in the mid-1960s, on computer terminals, as an interactive and more user ...
References
{{Unix commands
Application layer protocols
Unix software