What Mosh does
Mosh keeps a session going when the network changes, for example from Wi-Fi to cellular data, or when the device sleeps. On a slow connection it shows what you type at once and confirms it when the server answers. It signs in over SSH first, with the usual host key check and login, then talks to the server over UDP.
Prepare the server
- Install Mosh. On Debian or Ubuntu:
On Fedora or Rocky Linux:sudo apt install moshsudo dnf install mosh - Make sure the server has a UTF-8 locale, such as
en_US.UTF-8orC.UTF-8. - Open the UDP ports 60000 to 61000 on the server and in your provider's firewall:
sudo ufw allow 60000:61000/udp
Turn on Mosh
- Open the server, choose Show more, then Connection.
- Set Mosh to On. On a group, every server in it uses Mosh unless it chooses otherwise.
- If
mosh-serveris not on the server's path, write its full path in mosh-server command. - Connect.
The same with the Mosh command line:
mosh --server=/usr/local/bin/mosh-server deploy@203.0.113.10Local echo
Under Local echo, choose when the app shows your typing before the server confirms it:
- On a slow connection, the default: only when the delay is noticeable.
- Always.
- Never.
Text not yet confirmed is underlined. If the server shows something else, the app takes it back.
Good to know
- Mosh always uses UTF-8: the character set of a server applies when Mosh is off.
- While the server cannot be reached, a bar says how long it has been and Mosh keeps trying.
To keep programs running after you close the app, see Keep sessions alive. More on the Mosh page. Something does not work? See Mosh does not start.