Mosh, which stands for Mobile Shell is a command-line application which is used for connecting to the server from a client computer, over the Internet. It canbe used as SSH and contains more feature than Secure Shell.
It is an application similar to SSH, but with additional features. The application is written originally by Keith Winstein for Unix like operating system and released under GNU GPL v3.
Features of Mosh
Remote terminal application that allows roaming, supports intermittent connectivity, and provides intelligent local echo and line editing of user keystrokes.
Mosh is a replacement for interactive SSH terminals. It’s more robust and responsive, especially over Wi-Fi, cellular, and long-distance links.
Mosh is free software, available for GNU/Linux, BSD, macOS, Solaris, Android, Chrome, and iOS.
Replaces interactive SSH. Instant keystroke response, robust to roaming. But you’ll need working UDP.
How Mosh works
Remote-shell protocols traditionally work by conveying a byte-stream from the server to the client, to_be interpreted by the client’s terminal. (This includes TELNET, RLOGIN, and SSH.) Mosh works differently and at a different layer. With Mosh, the server and client both maintain a snapshot of the current screen state. The problem becomes one of state-synchronization: getting the client to the most recent server-side screen as efficiently as possible.
This accomplished using a new protocol called the State Synchronization Protocol, for which Mosh is the first application. SSP runs over UDP, synchronizing the state of any object from one host to another. Datagrams encrypted and authenticated using AES-128 in OCB3 mode. While SSP takes care of the networking protocol, it is the implementation of the object being synchronized that defines the ultimate semantics of the protocol.
Mosh runs two copies of SSP, one in each direction of the connection. The connection from client to server synchronizes an object that represents the keys typed by the user, and with TCP-like semantics. The connection from server to client synchronizes an object that represent the current screen state, and the goal is always to convey the client to the most recent server-side state, possibly skipping intermediate frames.
Because SSP works at the object layer and can control the rate of synchronization (in other words, the frame rate), it does not need to send every byte it receives from the application. That means Mosh can regulate the frames so as not to fill up network buffers, retaining the responsiveness of the connection and making sure Control-C always works quickly. Protocols that must send every byte can’t do this.
Installation of Mosh Shell in Linux
On Debian, Ubuntu and Mint alike systems, you can easily install the Mosh package with the help of apt-get package manager
$ sudo apt-get update $ sudo apt-get install mosh -y
And in RHEL/CentOS/Fedora based distributions, you need to turn on third party repository called EPEL, in order to install mosh from this repository using yum package manager
# yum update # yum install mosh
On Fedora version, you need to use dnf package manager to install mosh
# dnf install mosh
On Arch/Manjaro Linux :
# pacman -S mosh
And in OpenSuse Linux:
$ sudo zypper in mosh
On Gentoo :
# emerge net-misc/mosh
How do I use Mosh Shell?
1. Try to login into remote Linux server using mosh shell.
$ mosh firstname.lastname@example.org
Enter the password
2. Assume that the default SSH port 22 changed to port 70, in this case you can define custom port with the help of ‘-p‘ switch with mosh.
$ mosh email@example.com --ssh="ssh -p 70"
3. Check the version of installed Mosh.
$ mosh --version
4. You can close mosh session type ‘exit‘ on the prompt.
5. Mosh supports a lot of options, which you may see as:
$ mosh --help
Notes about Mosh
Mosh requires additional prerequisite for example, allow direct connection via UDP, which was not required by SSH.
Dynamic port allocation in the range of 60000-61000. The first open fort is allocated. It requires one port per connection
Default port allocation is a serious security concern, especially in production.
Scrollback not supported and no support for ssh-agent forwarding.