Stumbled upon Mobile shell (Mosh) which allows persistent connection over intermittent connections, VPN – WiFi – networking roaming etc. Its quite useful especially when we have tons of nodes across multiple cloud providers & resulting attempts of their attention grabbing. Automating few things in a CRM made us end up setting up a Postfix mail server after something like more than a decade, got frustrated over the nearly non-existent internet provided by Asianet DSL & all credit of this goes to them.
TL;DR Here is a quick guide to get Mosh working on Mac & GNU/Linux flavours.
By default it uses 60000 to 61000 for establishing connections. We would need to open up some of these ports, say a subset of this in the fire wall mechanism that we use to get access to the servers.
There is a client & a server
I missed out this part ! Well, we need to install Mosh on the client and the server. (ie apt-get install mosh or yum install mosh on the servers too BOFH.)
On Amazon / AWS / EC2 cloud,
Open up few UDP ports in the security groups. We opened up 10 ports.
On DigitalOcean or any other provider open the ports in your firewall.
Client side installation:
On Mac, we ran into issues with libprotobuf
The solution is to upgrade Brew (well why shouldn’t one use brew ?)
brew update ; brew upgrade ; brew remove libprotobuf ; brew install libprotobuf
will do the magic. If not, we can try
as well. If its doesn’t work, RTFM & the FAQ 🙂
Another issue we ran into was the locale & UTF-8 encoding. We fixed it by installing the locale in the client and server and exporting the following environment variable to the bash profile.
# for mosh
You load the environment variables by doing the following in bash.
. ~/.bash_profile # don’t miss the dot at the beginning
Firewalls, Tunnelling, NAT
It may not work just yet as you may have to deal with NAT traversal and other nasty things. Creating an SSH tunnel can solve these issues.
PS: if you use CIRU.org, things may be different for you.
That’s it. DigitalOcean guys have come up with a nice write up here which is very helpful. There is also an Android client and iOS client in the making. On GNU/Linux I use KDE Konsole & on Mac iTerm : these are 2 good tools that are very useful IMHO.