SSH, Mosh and tmux

In one way or another, this post has been written thousands of times across the web. I'm rewriting it for two reasons:

  • Command reference
  • mosh under Cygwinerror.

Mosh (mobile shell)

Mosh uses UDP to create an unbreakable ssh session. If you're on the road with flaky connections, it's a lifesaver.

On Windows, you can use mosh either in WSL or Cygwin. If using via Cygwin, you may stumble on the error «Did not find remote IP address (is SSH ProxyCommand disabled?)».

$ ./mosh frankie@192.168.5.2
CreateProcessW failed error:2
posix_spawnp: No such file or directory
./mosh: Did not find remote IP address (is SSH ProxyCommand disabled?).

To fix it, it's a simple as passing a few extra parameters:

$ ./mosh --predict=always --experimental-remote-ip=remote frankie@192.168.5.2

--predict=controls use of speculative local echo
--experimental-remote-ip= used to discover IP address mosh connects to

Notice that if you're having errors connecting, you should check if you're actually allowed to UDP into the server. For that, use netcat.

nc -u <host> <port>

check connection to mosh server (generally port 60001)

tmux (terminal multiplexer)

tmux puts your terminal connection into a proper session. Say you're working on a remote server from your home. You can disconnect that session. Go to work and resume the session exactly as it was.

On top of that, it allows you to easily split the screen.

tmux new - to start
tmux new -s session-name - to name the session
tmux -t session-name - to attach to the named session

During the session, your go-to command is Ctrl-b.

Ctrl+b % - splits the screen vertically
Ctrl+b " - splits the screen horizontally
Ctrl+b x - closes current session

Enjoy your super-powered ssh connection!

I've never had one of these iPhone cables fail.

Even after being chewed up by Roomba. It's funny how Amazon does a better iPhone cable than Apple, but there you have it. Can't recommend them enough.