If you’re not familiar with Mosh, it’s like SSH: a remote (terminal) connection to another machine. Unlike SSH, though, a single session can survive disconnects: it sets up a small server on the host machine and will reestablish the connection if it drops. It also responds immediately when you’re typing, even if there’s serious lag to the other server – it just gives you a nice visual signal (underlining) to let you know the other side hasn’t received what you’ve typed. This seems pretty nice, so I thought I’d set it up on my iMac so I could hit it from my iPad.
This isn’t complicated, but it also isn’t well-documented after the first step!
- via the binary on their site
- by running
brew install mosh
Find the install location for the server from your Terminal:
$ which mosh-server
Configure the firewall to allow the mosh server to install connections.
- Open the Security and Privacy pane of the System Preferences app.
- Choose the Firewall tab. Unlock it to make changes.
- Click Firewall Options.
- On the pane that opens, click the + button to add a new rule.
- Navigate to the location you got in step 2 above. (One easy way to do this: hit ⌘ Cmd⇧ ShiftG, and paste in the output from the
whichcommand.) Click Add.
- Find “mosh-server” in the list, and set it to Allow incoming connections.
- Hit OK.
Persuade macOS to reload its firewall rules. (This may not be necessary, but it was for me.) You can do one of the following:
- restart your machine
reload the normal rules manually:
$ sudo pfctl -f /etc/pf.conf
You may also need to open these ports on your router firewall. You should consider carefully whether you want a bunch of open ports sitting there or whether you want to just use a specific port and then always target that specific port by running mosh with the
$ mosh -p 60000 email@example.com
If you can connect locally but not remotely, this is probably what you need!
That should be all you need!