Mosh - a better SSH ?

Mosh, the mobile shell, is a terminal application that allows roaming, supports intermittent connectivity, and provides intelligent local echo and line editing of user keystrokes.

Mosh 1.0 was released in March 2012 and reached version 1.2.6 in August 2016.

It uses SSH to authenticate a session which then continues using encrypted UDP to carry a new protocol called SSP, or State synchronisation Protocol.

The big issue with SSH is lack of roaming - the ability to disconnect from a remote session on one device and connect with another to that same session.

However, SSH does things that Mosh can't. For example X11 Forwarding is not yet supported.

Mosh is available on Linux, Android, MacOS, etc...

Most requires one UDP port per connection (it uses the range 60000–61000). This may require opening additional firewall ports. However using a VPN may circumvent this requirement.

Try it out: install on two hosts:

$ sudo pacman -S mosh

Then from local_host, connect one to the remote_host:

$ mosh remote_host

Initial impressions are that it just works.

The documented escape CTRL^ does not work. I found that CTRL~ brings up a mosh bar instead.

However, I could not detach. I've just realised that isn't how it works. You can't detach but an running client will survive loss of connectivity. Closing the client terminates the server session. You can instead suspend (CTRL Z).

So mosh isn't an alternative to SSH with tmux.

So Mosh is really for those occasions when an unreliable or intermittent connection would make using SSH difficult. It's a useful additional tool in one's box but it isn't a replacement for SSH or screen/tmux.

Mosh over OpenVPN:

I see no reason why using Mosh over OpenVPN would not just work.