SSH (Secure Shell) is the most popular remote terminal application used nowadays, which runs inside a terminal emulator. Unfortunately, the SSH tool is not suitable for mobile networks. It has two major weaknesses. As SSH runs in TCP, it does not support roaming among IP addresses and SSH operates strictly in character-at-a-time mode, with all echoes and line editing performed by the remote host. To counter the shortcomings of SSH, a new technology called MOSH (mobile shell) was implemented.
Mosh defined as the mobile shell is a remote terminal application that supports IP roaming, intermittent connectivity, and marginal network connections. Mosh performs predictive client-side echoing and line editing without any change to server software and regardless of which application is running. Mosh is built on the State Synchronization Protocol (SSP) a new UDP-based protocol that securely synchronizes client and server state, even across different IP addresses of the clients. Mosh uses SSP to synchronize a character cell terminal emulator, maintaining terminal state at both client and server to predictively echo keystrokes.
Mosh makes remote servers feel more like local computers because most keystrokes are reflected immediately on the user’s display even in full-screen programs like a text editor or mail reader. These features are possible because Mosh operates at a different layer from SSH. Mosh contains a server-side terminal emulator and uses a new protocol to synchronize terminal screen states over the network, using the principle of application-layer framing. When both the server and client maintain an image of the screen state, Mosh can support intermittent connectivity and local editing and can adjust its network traffic to avoid filling network buffers on slow links.
- Mosh keeps the session alive, even if the client leaves or temporarily loses his Internet connection.
- Mosh adjusts its frame rate so as not to fill up network queues on slow links. So ‘Control-C’ always works within an RTT to halt a runaway process.
- Mosh warns the user when he has not heard from the server in a while.
- Mosh supports lossy links that lose a significant fraction of their packets.
- Mosh handles some Unicode edge cases better than SSH and existing terminal emulators by themselves but requires a UTF-8 environment to run.
- Mosh leverages SSH to set up the connection and authenticate users. Mosh does not contain any privileged (root) code.
- Prerequisites to the server: Mosh requires the server to fulfill additional prerequisites, which are not needed by ssh.
- One port per connection.
- Mosh does not support Ipv6, X11 forwarding, ssh-agent forwarding.
- Scrollback is not supported in the current release of mosh.
You can go through the Mosh official site https://mosh.mit.edu/ for getting the installation packages of Mosh for different Linux distributions.
For making Mosh access from a client to the server, you may have to install the binaries of Mosh in both client and server machines. The syntax used for Mosh is the same as the one we have used for SSH access.
The user runs:
$ mosh [user@]host
If the mosh-client or mosh-server binaries live outside the user’s path, mosh accepts the arguments as –client=PATH and –server=PATH to select alternate locations. More options are documented in the mosh manual page.