How do I ssh on slow/flaky connections?

Try Mosh.

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.

Mosh is free software, available for GNU/Linux, FreeBSD, Solaris, Mac OS X, and Android.


an alternative (and also in addition) to dmourati answer: use screen or tmux or other things, to keep sessions alive when you are disconnected. (You simply re-attach to the session after you reconnect, and see the terminal as you left it, even with full screen programs [vi, etc]). It also have many other benefits (sharing sessions with co-workers, etc) (as in Mosh own faq it states:

Q: Why is my terminal's scrollback buffer incomplete?

Mosh 1.2 synchronizes only the visible state of the terminal. Mosh 1.3 will have complete scrollback support; see this issue and the others which are linked from there. For now, the workaround is to use screen or tmux on the remote side.

And you should also use rsync to copy files, without having to re-send already sent parts over the network when the connection dies.


You should see where the latency/bottleneck(s) are. You should try to get better access to infrastructure... either locally or at the provider's side. You wrap your important or critical sessions in tmux or screen multiplexers...

Please give us numbers. It takes a particularly-bad connection for simple SSH sessions to have problems... I've had to access systems on the other side of the world from an airplane over a VPN and still haven't had too much trouble. Is this a persistent issue? What does traceroute tell you?