SSH, Mosh and tmux

Frankie
2 min readOct 30, 2023

--

If you’re using secure shell to remote, Mosh and tmux should be part of your arsenal.

Originally published at https://wasteofserver.com on October 30, 2023.

This post has already been written, in one way or another, thousands of times across the web.

I’m rewriting it for two reasons, command reference and mosh under Cygwin error.

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 [email protected]

--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>

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!

Originally published at https://wasteofserver.com on October 30, 2023.

--

--

No responses yet