Mosh a New and Better Way to SSH Remote Server


If you have used SSH to remote control any Linux or Unix server, you will know that you need to reconnect to the server again every time you lose the connection, and you need to enter your credentials repeatedly. The speed of network also determines how smooth your SSH terminal experience is. A poor connection would result in having you to wait for responses back from the server for every keystroke entered into the terminal. Previously, we’ve covered a method that uses Public and Private key authentication to eliminate the need for a password, which is also more secure as well. However, that doesn’t solve the problem with bad connection and slow response from SSH terminal.

Mosh, developed by MIT students, solved those problems. It runs over UDP, synchronizing the state of any object from one host to another. That also means you can have a remote shell running while you are roaming around to a different network. It will handle auto reconnections for you all in the background. Mosh leverages a new protocol called State Synchronization Protocol (SSP)

Mosh runs two copies of SSP, one in each direction of the connection. The connection from client to server synchronizes an object that represents the keys typed by the user, and with TCP-like semantics. The connection from server to client synchronizes an object that represent the current screen state, and the goal is always to convey the client to the most recent server-side state, possibly skipping intermediate frames.

Setup Mosh on Server and Client

Because Mosh uses a new Protocol, you need to configure both the server and client to use SSP. Mosh supports most of the Linux and Unix distributions on the server side, and all platforms for the client connection.

For example, we are going to use Windows as the client to connect to a server that already has Mosh installed. On Windows, you can grab it via Chrome Extension.

2016 05 19 0826 thumb - Mosh a New and Better Way to SSH Remote Server

Once you have installed the Mosh as Chrome extension, you should be able to find it as a standalone application from the start menu. Launch the client app, and it will prompt you to enter the remote host credentials connect to the server as you would normally.

2016 05 18 1652 thumb - Mosh a New and Better Way to SSH Remote Server

Once you start the session, it will launch Mosh client, from here on all the magic of eliminating lag and auto reconnect to the server are handled for you in the background.

2016 05 18 1652 001 thumb - Mosh a New and Better Way to SSH Remote Server

If you use relies on SSH for your day-to-day work, consider trying to use it More. Below is a screencast that talks in-depth of how different Mosh is comparing to the traditional SSH.



Please enter your comment!
Please enter your name here