This articles introduces mosh, discusses the differences and tradeoffs of ssh and mosh, and also shares experiences about using mosh.

Mosh is a tool to connect your client and server, just like ssh does. It has its strong sides and weak sides, as discussed in the following sections.


Strong Sides

Mosh was proposed to addressed two major pain points of ssh.

Ssh Connection Reset Problem

Ssh connection will be down if there is any temporary network issue, or if you put your client OS to sleep. This is because ssh is TCP based, and TCP cannot survive if there is long network outage.

This usage case is very common. Say I connect to my dev server at office network, and I close the lid of my laptop when I’m going home. Once I’m back home, Ideally, my connection to the dev server should still be there, so that I don’t need to reconnect. However, this is not possible with ssh.

Mosh addressed the problem by leveraging UDP. Since UDP is connectionless, it opens up the possibility of keeping the connection while network is temporarily down. Using mosh, you won’t have to reconnect to your server after temporary network outage or closing the lid of your laptop for a while, which is pretty handy.

Ssh Typing Lag

There is a significant typing lag if the network has a high latency, because it needs a round trip for the typed char to pop up on screen. Mosh addressed the issue by guessing the chars to pop up on screen, and do it before hand. Once the real char comes back, mosh will make the correction. So mosh makes the coding experience more smooth.

Weak Sides

Mosh did address the big pain points of ssh, but there is also one big caveat. Mosh does not support ssh tunneling. When you set up a ssh connection, you can set up a port-forwarding with the -L or -R commands, allowing you to map one port from your server network to you client network. This feature is sometimes useful.

Mosh and ssh each has its strong sides and week sides. But in general, mosh is a better choice for most of the cases. I use mosh almost every day, and only switch to ssh temporarily when port forwarding is needed.

Which Version To Use?

On Oct 31th, 2022, mosh released its version 1.4.0. There are two intersting features released in this version:

  • OSC 52 clipboard copy integration: it allows you to copy text from remote server directly to your client clipboard, which is amazing!
  • True color support: this allows you to see true color in terminal, which is also cool.

I’d highly recommend this version, as these features will be pretty helpful to you.


Install Mosh Client On Mac OS

Mosh version 1.4.0 is already integrated with homebrew. So to install mosh on the mac side, just do:

brew install mosh

Install Mosh Server On Linux

Since mosh version 1.4.0 is released recenty, there is a good chance that your apt repository does not have it yet. In this case, you can build it from source code with the following commands:

sudo apt-get install automake libtool g++ protobuf-compiler libprotobuf-dev libboost-dev libutempter-dev libncurses5-dev zlib1g-dev libio-pty-perl libssl-dev pkg-config -y
git clone
cd mosh
sudo make install

If you are using a very new Linux version, and it includes mosh 1.4.0, you’ll need to do the following to install mosh:

sudo apt install mosh


Once mosh is installed, you can just use it like ssh, e.g.,

mosh {username}@{server-ip}

Here {username} is the name of the user you want to use to log in to the server, and {server-ip} is an accessible IP for the target Linux server.