mosh (mobile shell)

Remote terminal application that allows roaming, supports intermittent connectivity, and provides intelligent local echo and line editing of user keystrokes. Mosh is a replacement for SSH. It’s more robust and responsive, especially over Wi-Fi, cellular, and long-distance links.

How to install

server

FreeBSD:

$ pkg install net/mosh

Edit /etc/login.conf and add this to the default:

    :charset=UTF-8:\
    :lang=en_US.UTF-8:\
    :setenv=LC_COLLATE=C:

After editing /etc/locing.conf run:

$ cap_mkdb /etc/login.conf

Client

In a mac OS X;

$ brew install mosh

How to use

Basically just type mosh instead of ssh, Mosh will log the user in via SSH, then start a connection on a UDP port between 60000 and 61000., Mosh will log the user in via SSH, then start a connection on a UDP port between 60000 and 61000.

$ mosh your.server.tld

or

$ mosh [email protected]

Selecting SSH port:

$ mosh --ssh="ssh -p 2222" your.server.tld

or

$ mosh [email protected] --ssh="ssh -p 2222"

Specify ssh key:

$ mosh --ssh="ssh -i ./identity" your.server.tld

or

$ mosh --ssh="ssh -i ~/.ssh/id_rsa_devops -p 2222" 192.168.1.4

With tmux:

$ mosh host --ssh="ssh -p 3333" -- sh -c "tmux -2 attach -t $USER -d || tmux -2 new -s $USER"

More info: https://mosh.mit.edu/

mosh