Getting Mosh To Work

I've known about mosh for a long time, and it caught my eye years ago, but I never really got around to trying it. After suffering a bit of lag while editing blog posts over ssh from my netbook (typing 100+ wpm will do that when you're dealing with curses applications) I've decided to give it a shot. It's in OpenBSD's repositories, as well as SBo on Slackware, so it was easy enough to install, but it's not quite so easy to use.

As I understand it, the flow when you type "mosh foo" goes something like this:
1. Check that the $LANG on the local machine is UTF-8. Barf otherwise.
2. ssh into foo.
3. Start mosh-server on a random port on foo. Note the port it takes.
4. Send that port back to the client. run mosh-client with the port you were given by the server.

This understanding isn't quite complete, but it's good enough for my debugging purposes. When I try to mosh into my (OpenBSD 6.1) server from my (Slackware 14.2) netbook, it says that it received no information from the serve when it tried to connect. Since the helper script isn't working, then why don't we try running these commands manually?

Well, let's drop into X (there's a little bit of copy/paste for manual key exchange involved) and take a look.
ssh into my server and run mosh-server. In my case I chose to run mosh-server -vvvv because the man page doesn't say how many v's it wants to be really verbose.

Now head back to local, copy the info over and run mosh-client and works? Well, I guess that's one way to make my day more interesting isn't it?

Wait, though: there was one anomaly when I tried to run it. Since my server is upstairs, it's accessible over my lan, which gives some better latency. When using ssh I can simply say ssh server and an entry in /etc/hosts works out the connection. I tried this with mosh-client, and it didn't work at first. It didn't know what IP "server" was. Maybe running mosh ip rather than mosh server works? It did, weird.

Well, mosh is just a perl script, so maybe I should figure out why it chokes out on hosts entries when (presumably) it works when you go through the DNS system. I'm not going to open up the UDP ports it wants since I haven't looked into just how safe mosh is; the design seems okay, but I haven't heard much about it since its announcement. It seems like mosh just asks ssh about what the connection is. Weird. Well I do have that thing in my ssh config where I set the hostname to server if I ssh into my server's ip. That can't affect anything, right? Yep, that was it.

So, mosh seems to work well but you need to remember a couple of things:
1. Remember that your client language needs to be set to UTF-8. Sometimes I forget to do this. The server's locale doesn't matter since mosh sets it manually.
2. mosh gets very easily confused about hostnames and IPs. Make sure that you do not set any sort of HostName in your ssh config, at least not one that doesn't match exactly with the Host entry. The only reason that I have these HostName entries is because I saw them somewhere else when I was first making my config.

mosh works fine. The real lesson? Don't cargo cult your configs, kids.