Installing Mosh server on AWS

Also works for other VPS

Author

Richard Decal

Published

September 3, 2019

Mosh (“mobile shell”) is an ssh alternative which is robust to network changes. It is super useful for working on a VPS when you are on a flaky connection or roaming. Here is how to install Mosh on an AWS EC2 instance.

First, install and run mosh server:

sudo add-apt-repository ppa:keithw/mosh
sudo apt-get update && sudo apt-get upgrade
sudo apt-get install mosh
mosh-server  # start the server

Next, we need to open up firewall rules. I tried running the following code from another guide, which did not work:

sudo iptables -I INPUT 1 -p udp --dport 60000:61000 -j ACCEPT

Instead, I had to go to the AWS EC2 console and to open the rules. On the left, go to “Security Groups”. Select the group. Inside the Inbound tab, click “Edit” then “Add Rule”. You want the following settings:

Save, and now you should be able to access your VPS with mosh. Good luck!