Get your server issues fixed by our experts for a price starting at just 25 USD/Hour. Click here to register and open a ticket with us now!

Author Topic: How To Install and Use Mosh on a VPS  (Read 1499 times)

0 Members and 1 Guest are viewing this topic.

Vineesh K P

  • Guest
How To Install and Use Mosh on a VPS
« on: February 17, 2018, 06:23:18 pm »
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:
Code: [Select]
    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:
 
Code: [Select]
    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
Code: [Select]
    sudo iptables -I INPUT 1 -p udp --dport 60000:61000 -j ACCEPT
With ufw
Code: [Select]
    sudo ufw allow 60000:61000/udp

Usage

Code: [Select]
    mosh user@example.com
However, if you use any other arguments with SSH (such as -p), then a slightly different syntax is needed:

Code: [Select]
    mosh --ssh="ssh -p 22000" user@example.com
« Last Edit: February 17, 2018, 07:13:53 pm by Vineesh K P »