64

I ssh on remote host but terminal performance is poor. Symbols I am typing are not shown immediately, but with some delay. Sometimes two symbols are shown at one time after delay.

3
  • 1
    Mosh is a good ssh replacement to prevent this issue: mosh.mit.edu Jul 4, 2015 at 1:03
  • 6
    Why is this question closed? In my case it was def server side - a closed UDP port 67/68. There was DHCP enabled on a generic Vultr image, it was trying to renew pub IP constantly, but being blocked by CSF. Allowing those ports seemed to solve it, speedy SSH (and other network services) once again. Keep an eye out for that if you use that or other default/similar VPS images.
    – dhaupin
    Aug 18, 2016 at 20:32
  • 8
    This is clearly a (common) networking problem. I believe there is no reason to close it, and it is definitely not off topic. Even (particularly) when the problem can have multiple causes which are difficult to identify.
    – mivk
    Sep 3, 2016 at 9:54

11 Answers 11

24

High latency is another cause of poor ssh performance. I highly recommend using mtr as a better replacement for traceroute. It should be able to give you some idea of where your network problems might occur.

1
  • It is infact issue with my case. Any idea on how to solve it? May 13, 2020 at 5:11
24

Disabling X11 forwarding if you don't need it (ssh -x) and enabling compression (ssh -C) can also speed up your session.

2
  • 2
    did it for me...
    – Rob
    Sep 3, 2020 at 15:32
  • did not do it for me 😐
    – BND
    Feb 18, 2021 at 11:01
12

I can think of two possible causes:

  1. Packet loss on the connection
  2. High load on the server.
3

I tried to measure network performance by soon discovered that terminal was fine. What has happened?

We have a load balancing between two Internet channels router. Sometimes it routes my ssh traffic through wan1 and sometimes through wan2. I proposed, that there is something wrong with only one channel. So I measured network performance with mtr (great tool!) for two channels separately.

yeah! wan2 has 21 hops with 110 ms and wan1 has 15 with only 21 ms! wan2 latency is the problem.

3

Use Compression and CompressionLevel of 9. That should help a little. You can configure these parameters in /etc/ssh/ssh_config. But if actual network is very poor this tricks wont do much good.

2

The most obvious cause for this behaviour is link that is either saturated or dropping packets. How many hops do you have from your workstation to the machine you are ssh'ing into? Have you analyzed a traceroute, if applicable?

2

If you are using OpenSSH on a long-fat-pipe (high bandwidth + high latency) make sure you're using at least version 4.7 on both sides because it contains fixes to make OpenSSH use a bigger tcp window size.

 * The SSH channel window size has been increased, and both ssh(1)
   sshd(8) now send window updates more aggressively. These improves
   performance on high-BDP (Bandwidth Delay Product) networks.

This can be important if you want to use the connection to its full potential because otherwise a sender may have to wait for acks before it can continue sending.

1

As already said by others, it can come from latency, loss on you network, slow server.
Sometime you see 2 characters at one type because modern TCP stack use an algorithm called Naggle.

2
  • 1
    Nagle's algorithm is always disabled on interactive applications like telnet & SSH
    – LapTop006
    Jul 3, 2009 at 8:22
  • 1
    You don't have enough information to say 'always'. We don't know what ssh client/server he is using. We don't know the OS he is running. etc. With some OS a kernel level setting could have impact on TCP_NODELAY set at application level.
    – radius
    Jul 3, 2009 at 9:00
1

It could also be some SSH Brute Force attempt that throttles your connection. Every time my session runs slow I check the logs and in quite a number of cases someone is trying passwords like crazy.

1

Misconfigured DNS can cause this. The server will respond just fine once logged in, and upload and download files fairly fast, but SSH logins will be slow.

1
  • 1
    I found I can drop an IP entry in /etc/hosts for a server that has a slow SSH login and usually that speeds up the initial connection. But the real fix is to get the DNS working properly. May 6, 2010 at 7:55
1

One thing to look at is simply server memory. I was running an Ubuntu VM with 256Mb of memory and SSH was really sluggish. Doubling this to 512Mb solved the problem.

Not the answer you're looking for? Browse other questions tagged .