Mosh is a shell for mobile users. It carries a handful of features that make it great for users on the move:

  • auto reconnect after suspend/resume, network reconnect, etc
  • responsiveness on high delay networks
  • secure authentication
  • simple usage

Since I often travel by train when commuting to work, I experience insanely high delay (> 10s), which make remote typing a pain. And my internal 3G modem reconnects after lost signal, which brings me a new IP each time. Quite annoying.

A few weeks back someone mentioned mosh and after a few minutes I was hooked. The auto-reconnect is awesome. When using e.g. irssi in a screen session on a remote server, the reconnect keeps me connected from the minute I open my laptop.

The handling of latency is done by doing local echo based on a predictive scheme, which keeps typos at a minimum. It even underlines letters not yet confirmed, so one knows what has and has not been received by the server.

To use mosh, simply install it on both the client and the server, and run mosh as was it ssh:

mosh <user@hostname>

After a successful login, you'll barely notice the difference. (Unless you are experiencing high lags...)

Until now, I used an alias to connect to irc:

alias irc="ssh <user@hostname> -t screen -U -aAdr -RR irssi irssi"

This makes it simple to connect and reattach to an irssi session. With mosh it was a little tricky to achieve a similar behaviour. After a little digging and a few attempts, I arrived at this solution:

alias irc='mosh <user@hostname> --ssh="ssh -tt" -- \
    zsh -i -c "screen -U -aAdr -RR irssi irssi"'