Mobile Shell is a free and fast remote terminal application. It allows roaming, supports intermittent connections, and provides intelligent local echo and line editing of user keystrokes. You are already familiar with SSH. Mosh aims to support typical interactive use of SSH. Due to its robustness and faster response, especially on Wi-Fi, cellular, and long-distance links, it is considered a good alternative to interactive SSH terminals. Mosh is also compatible with GNU/Linux, FreeBSD, Solaris, Mac OS X, and Android.
What is Mosh and how does it work?
Mosh is a free command-line software used to connect to servers from client computers via the Internet to run remote terminals. It can be used on GNU/Linux, BSD, macOS, Solaris, Android, Chrome, and iOS. Mosh is similar to SSH but has additional features designed to improve usability for mobile users. Mosh is smarter than SSH. While SSH clients wait for TCP responses from the server before displaying your input, Mosh displays your input in real-time and even provides underlined input predictions. The mosh program connects to user@host via SSH to establish a connection. As you know, SSH may prompt for a password or use public key authentication to log in. However, mosh runs the mosh-server process (as the user) on the server computer. This brings some obvious advantages over the well-known SSH connection.
On long-latency or unreliable links, Mosh is faster and more responsive. So, it is safe to say that Mosh is an alternative to SSH. When the connection is lost, Mosh will attempt to reconnect to you automatically, even without your notice.
Let's review the most important reasons for using Mosh instead of SSH:
1- Mosh maintains the connection state even if your IP changes.
2- Mosh will resume the connection to your network machine when your network is restored after losing internet connectivity or when you put your system to sleep.
3- You don't need to be a superuser to install or run Mosh.
4- Mosh clients log in to the server via SSH, providing the same credentials as before.
5- Mosh runs in your terminal, such as xterm, gnome-terminal, urxvt, Terminal.app, iTerm, emacs, screen, or tmux.
6- Unlike SSH, Mosh does not fill up the network buffer, so Control-C can always stop runaway processes. Suppose you request a 200MB file instead of 100MB; you can stop it immediately by pressing CTRL+C.
Advantages of Mosh Shell:
Now that you know more about Mosh Shell, if you are unsure whether to replace it with SSH, check out the following list:
1- Mosh is highly efficient.
2- Mosh works well on low-bandwidth or intermittent connections.
3- Connections persist on WiFi networks and interruptions, just like ET.
4- Mosh allows you to input while SSH and ET are still waiting for commands to complete or connections to be reestablished.
5- Mechanisms for handling packet loss.
6- Mosh can use the same old methods for logging in as SSH.
How to Install Mosh Shell on Ubuntu 20.04:
To install the Mosh package on your Ubuntu 20.04 system, you just need to run the following commands:
apt-get update -y
apt-get install mosh -y
Note: If you are running a firewall like iptables, use the following command to manually open these ports:
sudo iptables -I INPUT 1 -p udp --dport 60000:61000 -j ACCEPT
Configuring Mosh Shell as an SSH Alternative on Ubuntu Linux:
After installing the Mosh shell, you can start using it. Therefore, run the following command to connect to your remote system:
Then, you should be able to connect to your remote system. Additionally, you can check the installed version of Mosh by running the following command:
Mosh supports many options, to view all options, enter: