SSH Vs Mosh


Hello everyone, in our today’s article we will discuss about the two most prominent Linux/Unix based shell environments that is SSH and Mosh. SSH, also known as Secure Socket Shell, is a network protocol that provides administrators with a secure way to access a remote computer. Secure Shell provides strong authentication and secure encrypted data communications between two computers connecting over an insecure network such as the Internet. To use SSH, you’ll need to install the SSH client on the computer you connect from, and an SSH server on the computer you connect to. Under Linux, the most popular software provider is the OpenSSH project.
SSH is widely used by network administrators for managing systems and applications remotely, allowing them to log in to another computer over a network, execute commands and move files from one computer to another.

While Mosh (stands for Mobile Shell) is a replacement of SSH for remote connections to Unix/Linux systems that brings a few noticeable advantages over well known SSH connections. In brief, it’s faster and more responsive, especially on long delay and/or unreliable links. So we can say that Mosh is an alternative for SSH.

Installation of Mosh and SSH

OpenSSH is an open source product that contains both the client and server components. If you want to be able to accept SSH connections as well as request them, you’ll need the server software as well which you can install it with below command.


 # yum install openssh-server

For Ubuntu:

 # apt-get install openssh-server

ssh installation

Similarly you can easily install the Mosh package with the help of ‘apt-get’ package manager on your Debian, Ubuntu and Mint like systems as shown.

 # apt-get update
 # apt-get install mosh

installing mosh

Starting SSH and Mosh Services:

When you have installed SSH and Mosh on your server, you need to start ssh service but you don’t need to start anything for Mosh. Let’s run the following commands to check the version of installed packages of SSH and Mosh on your server.

 # systemctl restart ssh.service
 # ssh -V
 # mosh --version

sshvsmosh versions

Using SSH vs Mosh

When using SSH or Mosh terminal, you are telling a computer to perform an action for you. This action could be a copy action, paste action, a open file action, a change permission action, pretty much an action you perform in explorer or finder. You tell it to perform these actions by typing in commands. The syntax for connecting to a remote server with Mosh is similar to SSH in both cases whether you are using SSH or Mosh as shown.

For SSH:

 # ssh

using ssh

For Mosh:

 # mosh

using mosh

You can also connect to an SSH daemon that is running on an alternate port with below command.

# ssh -P 2222
# mosh --ssh="ssh -p 2222"

To know and use more options with mosh, run the following command with ‘–help’ parameter to get the list of its all available commands that you can use.

# mosh --help

mosh help

Disadvantages of Mosh over SSH

Mosh is one the best alternative to SSH but still there are some of its disadvantage; it requires additional prerequisite to allow direct connection via UDP, which was not required by SSH. Dynamic port allocation in the range of 60000-61000 and the first open fort is allocated that requires one port per connection. Default port allocation is a serious security concern, especially in production. Scrollback and XII is not supported. While there is no support for ssh-agent forwarding in Mosh.


Mosh has highlighted some of its key benefits over SSH on mobile connections but it may not replace your daily use of SSH, in situations where you are forced to rely on a slow connection, it can make the difference between being frustrated and being productive. But Mosh has some value added compared to SSH, such as intermittent connectivity, roaming capability, predictive text, UDP connections and ability to suspend it. Mosh also works on Linux, Unix, MacOS and Microsoft Windows platform.