Contents

Mosh – SSH replacement for unreliable network

Mosh (Mobile shell) is a remote terminal application that provides a robust and responsive experience when connecting to a remote server over an unreliable network. Mosh is used as a drop-in replacement for SSH (Secure Shell) and offers several advantages over traditional SSH connections.

Real-world scenario

Mosh can be particularly useful for users who need to connect to a remote server while on the move, such as when traveling on a train or bus. In such environments, network connections can be slow and unreliable, making it difficult to maintain an active SSH connection.

Here is an example of how Mosh can be used in a scenario like this:

  1. Connect to the remote server using Mosh from an iPad while on the train: mosh [email protected]
  2. Work on the remote server as you normally would, typing commands and receiving instant feedback.
  3. Turn off the iPad or go into a tunnel, where the network connection may be lost.
  4. Turn the iPad back on or exit the tunnel, and continue working on the remote server without needing to reconnect. Mosh automatically reconnects to the server and resumes the active session.

This demonstrates how Mosh can provide a seamless and uninterrupted terminal experience, even when the network connection is unreliable. Mosh maintains the active connection to the server, so the user can continue working without needing to reconnect, even after turning off the device or experiencing network interruptions.

Use cases

Use Cases for Mosh:

  • Mobile and wireless connections: Mosh is ideal for users who need to connect to a remote server while on the go, as it provides a robust and responsive experience over low-bandwidth and high-latency networks.
  • Remote development: Mosh is well-suited for remote developers who need to maintain an active connection to their development environment, even when the network is unreliable.

Use Cases for SSH:

  • Secure connections: SSH provides a secure encrypted connection between the client and server, making it ideal for sensitive data transfers.
  • Wide compatibility: SSH is widely available on most operating systems and servers, making it easy to set up and use.

Difference between Mosh and SSH

  • Mosh uses UDP (User Datagram Protocol) instead of TCP (Transmission Control Protocol) used by SSH. This allows Mosh to better handle network interruptions, lag, and packet loss.
  • Mosh provides local echo and line editing capabilities, which are not available in standard SSH connections.
  • Mosh maintains an active connection to the server even when the network connection is lost, and automatically reconnects when the network is available again.

However, there are some cons:

  • Limited compatibility: Mosh is not as widely used as SSH and may not be available on all servers.
  • Increased bandwidth usage: Mosh uses more bandwidth than SSH due to its use of UDP.

How to install Mosh

  • On Ubuntu and Debian-based systems, Mosh can be installed with the following command: sudo apt-get install mosh
  • On Fedora and CentOS systems, Mosh can be installed with the following command: sudo yum install mosh
  • On macOS systems, Mosh can be installed with the following command: brew install mosh

To use Mosh with an iPad, the Blink app can be used as the client. Blink is a popular SSH and Mosh client for iOS that provides a fast and responsive terminal experience.

In conclusion

Mosh provides a better terminal experience for users connecting to a remote server over an unreliable network. While it may not be as widely used as SSH, Mosh provides a robust and responsive experience, making it ideal for mobile and wireless connections.