Mosh (software)
Remote terminal From Wikipedia, the free encyclopedia
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.[2] Mosh is similar[3] 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 network or when changing from Wi-Fi to 3G.[4]
- 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.[5]
- A 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.[6][7]
![]() Mosh, showing a warning about an intermittent network connection and the local echoing feature | |
Original author(s) | Keith Winstein |
---|---|
Initial release | March 12, 2012 |
Stable release | 1.4.0
/ October 26, 2022[1] |
Repository | |
Operating system | Unix-like systems |
Type | Utility software |
License | GNU GPLv3 with OpenSSL and iOS exceptions |
Website | mosh |
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 Windows client.[2] 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 at the server to figure out what should be on the screen.[2] The server then transmits this screen to the client at a varying frame rate, depending on the speed of the network.[8] This allows Mosh to save on network traffic on slow or intermittent connections.
Supported platforms
Mosh is available for most Linux distributions, macOS, FreeBSD, NetBSD, and OpenBSD, Android, Solaris, Cygwin, and as a Chrome App.[2] The iOS program Termius includes an independent implementation of the Mosh protocol.[9]
Performance
Roaming
Mosh is built on the State-Synchronization Protocol (SSP),[10] which supports single-packet roaming.[11] 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 (NAT) when the NAT router roams.)[8]
Packet loss
In the Mosh research paper,[8] 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).[12]
Local echo
According to Mosh's developers, the program was found to be able to predict and immediately display 70% of user keystrokes,[2][8] 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.[13]
Drawbacks
Summarize
Perspective
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.[14] 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.[15]
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.[16] 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.[17]
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[18]
- 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
Output drops and lack of terminal scrollback
![]() | This section needs to be updated. The reason given is: We are at release 1.4 now, the section talks about features that will arrive in 1.3 (not sure if they ever did). (December 2023) |
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.[19] This functionality is a trade-off for garbage cleaning, as binary output is wiped away[clarification needed]. One way to mitigate this is by using Mosh in combination with a terminal multiplexer like screen or tmux.[20]
Lack of ssh-agent forwarding
ssh-agent forwarding is not currently supported.[21]
Lack of X11 forwarding
See also
References
Wikiwand - on
Seamless Wikipedia browsing. On steroids.