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 can be 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.

Mosh Shell SSH Client
Mosh Shell SSH Client

Features of Mosh

  1. It is a remote terminal application that supports roaming.
  2. Available for all major UNIX-like OS viz., Linux, FreeBSD, Solaris, Mac OS X and Android.
  3. Intermittent Connectivity supported.
  4. Provides intelligent local echo.
  5. Line editing of user keystrokes supported.
  6. Responsive design and Robust Nature over wifi, cellular and long-distance links.
  7. Remain Connected even when IP changes. It usages UDP in place of TCP (used by SSH). TCP time out when connect is reset or new IP assigned but UDP keeps the connection open.
  8. The Connection remains intact when you resume the session after a long time.
  9. No network lag. Shows users typed key and deletions immediately without network lag.
  10. Same old method to login as it was in SSH.
  11. Mechanism to handle packet loss.

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 as shown.

# apt-get update # apt-get install mosh

On 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 as shown.

# yum update
# yum install mosh

On Fedora 22+ version, you need to use dnf package manager to install mosh as shown.

# dnf install mosh

On other Linux distributions can install it as shown.

# pacman -S mosh [On Arch/Manjaro Linux]
$ sudo zypper in mosh [On OpenSuse]
# emerge net-misc/mosh [On Gentoo]

How do I use Mosh Shell?

1. Let’s try to login into remote Linux server using mosh shell.

$ mosh [email protected]
Mosh Shell Remote Connection
Mosh Shell Remote Connection

Note: Did you see I got an error in connecting since the port was not open in my remote CentOS 7 box. A quick but not recommended solution I performed was:

# systemctl stop firewalld [on Remote Server]

The preferred way is to open a port and update firewall rules. And then connect to mosh on a predefined port. For in-depth details on firewalld you may like to visit this post.

  1. How to Configure Firewalld in CentOS, RHEL and Fedora

2. Let’s assume that the default SSH port 22 was changed to port 70, in this case you can define custom port with the help of ‘-p‘ switch with mosh.

$ mosh -p 70 [email protected]

3. Check the version of installed Mosh.

$ mosh --version
Check Mosh Version
Check Mosh Version

4. You can close mosh session type ‘exit‘ on the prompt.

$ exit

5. Mosh supports a lot of options, which you may see as:

$ mosh --help
Mosh Shell Options
Mosh Shell Options

Cons of Mosh Shell

  1. Mosh requires additional prerequisite for example, allow direct connection via UDP, which was not required by SSH.
  2. Dynamic port allocation in the range of 60000-61000. The first open fort is allocated. It requires one port per connection.
  3. Default port allocation is a serious security concern, especially in production.
  4. IPv6 connections supported, but roaming on IPv6 not supported.
  5. Scrollback not supported.
  6. No X11 forwarding supported.
  7. No support for ssh-agent forwarding.

Conclusion

Mosh is a nice small utility which is available for download in the repository of most of the Linux Distributions. Though it has a few discrepancies specially security concern and additional requirement it’s features like remaining connected even while roaming is its plus point. My recommendation is Every Linux-er who deals with SSH should try this application and mind it, Mosh is worth a try.


Discover more from Hosting Mate

Subscribe to get the latest posts sent to your email.

Similar Posts