22

I am dealing with a really slow shell connection. It is in the cloud and I am very far from the server. My connection also breaks sometimes as it is over the internet and I may also be using shared Wifi or 3G. Is there a way to see what I type instantly? Trying to type commands and waiting for each character is atrocious.

1
  • 4
    Use "screen" to hold your session alive, so that you can reconnect when you disconnect.
    – Konerak
    Dec 2 '13 at 10:36
25

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.

4
  • 3
    Caveats to mosh: (1) it's much more cpu intensive than ssh. (2) If your mosh session doesn't end normally, you'll have a leaked connection that can never be re-established. (I have to houseclean my shell box otherwise there will be dozens of processes running).
    – user606723
    Dec 2 '13 at 18:44
  • Another issue is that it is near impossible to install on linux distro like Suse (SLES). I spent hours trying to install it as either an openSuse package or compiling it from source.
    – Zombies
    Dec 4 '13 at 2:20
  • $ sudo zypper in mosh (acording to the docs)
    – dmourati
    Dec 4 '13 at 5:28
  • Yes that will work fine on openSuse, but a corporate/closed distro it is very tasking to install new open source projects.
    – Zombies
    Dec 6 '13 at 9:03
10

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.

0
2

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?

1
  • The issue occurs on hotel wifi a lot, where there are too few routers and too many devices/laptops sharing internet access. Also shared hotel wifi is inherently pretty crummy with ping times as going through 1 or more walls really adds a lot of ms delay. That is also another major bottleneck. Similar situation occurs on 3G, where that much distance to the cell phone tower adds MS. When using SSH shells, I have to wait for each character. A MS of 200-400 can be pretty annoying, but with spikes of up to 1 second... ouch.
    – Zombies
    Dec 4 '13 at 2:18
2

For future readers of this thread, @lowellheddings' tip in his blog, together with the use of screen, could help overcome this issue:

You can configure the ssh client to automatically send a protocol no-op code code every number of seconds so that the server won’t disconnect you. This setting is sometimes referred to as Keep-Alive or Stop-Disconnecting-So-Much in other clients.
Add the following line to the /etc/ssh/ssh_config file:
ServerAliveInterval 60
...

1
  • I've done this both on client and server (ClientAliveInterval) and disabled TCPKeepAlive, but it still drops with client_loop: send disconnect: Broken pipe. Any clue?
    – M. Volf
    Mar 11 at 21:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.