Installing Mosh server on AWS

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:
Type: Custom UDP
Port Range: 60000 - 61000
Source: leave the default value, which should be 0.0.0.0/0; ::/0

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

Copyright Richard Decal. richarddecal.com