DEV Community

wasteofserver
wasteofserver

Posted on • Originally published at wasteofserver.com on

SSH, Mosh and tmux

SSH, Mosh and tmux


This post was originally posted on wasteofserver.com, you may find newer revisions and additional comments there.


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?).
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

--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>
Enter fullscreen mode Exit fullscreen mode

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

SSH, Mosh and tmux
Enjoy your super-powered ssh connection!


SSH, Mosh and tmux

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.

Top comments (0)