Mosh hasn’t had a release in quite a while (Oct 2022). While that’s not that old, and there does appear to be somewhat active development, it’s a little slow moving for something that might be open to the internet directly. I used to use it but ssh with tmux is mostly fine and makes me feel a little safer because of their wider use.
Hopefully talking about it more will interest more people in the project and possibly interest more people in contributing
mosh with tmux makes it really painful when you have to go back to plain ssh
I worked with mosh for years to connect to servers on other continents. It was impossible to work otherwise. It only has two small warts: forwarding, and jump hosts.
The second is fixable/ish with an overlay network, but that isn’t always an option if you don’t control the network. I tried to solve this with socat but wasn’t able to configure it correctly - something about the socket reuse flag was very unhappy.
Yeah. I spend a majority of my working time on a slightly-unreliable Wifi network, and getting irritated that my keystrokes are lagging by some seconds and making it hard to e.g., edit the line I’m editing, is a daily occurrence. I literally had never heard of mosh before today, and when I tried it it was like the heavens opened up.
TCP was never designed with wifi in mind. TCP retransmission was only ever meant to handle drops due to congestion, not lossy links.
Tmux is a wonderful complement to mosh. Together you get persistence even when your local client loses power (speaking from experience)
I still remember the professor in my networks class explaining how TCP worked, and then saying more or less:
Why doesn’t it send a detailed mapping of which sections of the stream have been received and which haven’t, allowing retransmission of only the dropped packets instead of what it does which is just backing up and blasting a whole new window’s worth every time a single packet is dropped? Well, I don’t know. It’d be a little more complex but the improvement in functionality would be so obviously worth it that it should. Don’t know what to tell you. Anyway, this is how it works…
TCP Selective Ack is very much a thing, but it does take extra memory so lots of TCP stacks exclude it or disable it by default.
Mosh is great but it annoyingly doesn’t preserve scrollback. So it needs to be combined with something like Tmux if you want to be able to see more than one page of terminal.
deleted by creator
Personal bias: I’m a SSH/tmux zealot
How is this different/better than connecting to a tmux session on a remote machine?
When you push up, up, Ctrl-A right right right, you don’t have to sit there for 5 seconds and wait for the machine to decide it feels like fulfilling your request and showing you where the cursor is now so you can get on with what you were doing.
If you’re not on flaky wireless networks a lot it might not be a huge difference, but from my experience today it was a big difference.
Ctrl-a! love learning new things
Thanks for sharing :)
Haha no problem. Yeah, Ctrl-A, Ctrl-R, Ctrl-K, and Ctrl-right/left are godsends for mucking around in the terminal, in case there were others of those you didn’t know. Probably there are lots more but those are the ones I use all the time.
Using fish with mosh always wasn’t quite working as I wanted. The auto completions were always behind.
Did you create an issue for it? Sounds like something that’d be worth them fixing.
What do you guys think about Eternal Terminal? I quite like it. You can scroll!
I had problems with CPU use; it has a polling model that wasn’t very well tuned. The dev(s) are responsive, and suggested a work-around which helped the server, but eventually I went back to mosh. All my mosh connections are into tmux sessions, so the et benefits were not noticeable, and mosh is lighter on resources.
How does this differ from something like tmux?
Tmux allows you to reconnect to a session, and helps guarantee that you will always be able to get back to your long running processes. For important long running processes, I still use tmux with mosh, because if the mosh client is killed (or you’re trying to “re-attach” from a different device, mosh won’t let you “re-attach” to that “session”.
Mosh allows you to roam, and suspend your machine, and whenever you resume it again, whatever network you’re now on, the connection is basically instantly re-established. You can often roam from WiFi to cellular data without even noticing. (Great when working from a phone, or just a laptop)
In my opinion, they are mostly orthogonal (and complementary).
Here’s the list of features from the home page. I’ve added my own comments after ‘*’. If there is no ‘*’, then the feature doesn’t exist for tmux (because it’s outside the scope of tmux):
Change IP. Stay connected. Mosh automatically roams as you move between Internet connections. Use Wi-Fi on the train, Ethernet in a hotel, and LTE on a beach: you’ll stay logged in. Most network programs lose their connections after roaming, including SSH and Web apps like Gmail. Mosh is different.
Makes for sweet dreams. With Mosh, you can put your laptop to sleep and wake it up later, keeping your connection intact. If your Internet connection drops, Mosh will warn you — but the connection resumes when network service comes back.
Get rid of network lag. SSH waits for the server’s reply before showing you your own typing. That can make for a lousy user interface. Mosh is different: it gives an instant response to typing, deleting, and line editing. It does this adaptively and works even in full-screen programs like emacs and vim. On a bad connection, outstanding predictions are underlined so you won’t be misled.
No privileged code. No daemon. * Same for tmux, but that’s less interesting since tmux is not a network service You don’t need to be the superuser to install or run Mosh. The client and server are executables run by an ordinary user and last only for the life of the connection.
Same login method. * Not really relevant to tmux, which doesn’t handle auth Mosh doesn’t listen on network ports or authenticate users. The mosh client logs in to the server via SSH, and users present the same credentials (e.g., password, public key) as before. Then Mosh runs the mosh-server remotely and connects to it over UDP.
Runs inside your terminal, but better. * This is common to both Mosh is a command-line program, like ssh. You can use it inside xterm, gnome-terminal, urxvt, Terminal.app, iTerm, emacs, screen, or tmux. But mosh was designed from scratch and supports just one character set: UTF-8. It fixes Unicode bugs in other terminals and in SSH.
Control-C works great. * Tmux can help with this too Unlike SSH, mosh’s UDP-based protocol handles packet loss gracefully, and sets the frame rate based on network conditions. Mosh doesn’t fill up network buffers, so Control-C always works to halt a runaway process.
I’m no expert, but this isn’t a terminal multiplexer.
Mosh is to SSH as Tmux is to Bash