SSH is, without a doubt, the de facto method for remote server administration. However, its dominance doesn't mean it's without its own nuances under certain circumstances. If you have ever tried to maintain an SSH connection while on the move with a mobile connection, you'll appreciate this sentiment.
Mosh takes all the security benefits of SSH and builds upon it a greater tolerance to poor network conditions and roaming connections. It also increases responsiveness and lowers bandwidth usage by only communicating state changes to the currently visible screen region, rather than transmitting complete buffers.
Connection initiation and authentication with Mosh occurs through a regular SSH connection, meaning only a few extra configurations are required and any current key-based security mechanisms will work flawlessly. Once authenticated, a key is negotiated and Mosh switches to communicating through encrypted UDP datagrams, making the session more resilient to the changing client IPs and connection dropouts that can be common with mobile connections.
Installation
On Ubuntu:
sudo apt-get install python-software-properties
sudo add-apt-repository ppa:keithw/mosh
sudo apt-get update
sudo apt-get install mosh
On CentOS:
sudo yum install mosh
Firewall Configuration
If you have a firewall configured on your VPS (recommended), you will also need to open the extra ports Mosh requires.
With iptables
sudo iptables -I INPUT 1 -p udp --dport 60000:61000 -j ACCEPT
With ufw
sudo ufw allow 60000:61000/udp
Usage
mosh user@example.com
However, if you use any other arguments with SSH (such as -p), then a slightly different syntax is needed:
mosh --ssh="ssh -p 22000" user@example.com