Yesterday I got my Raspberry Pi B+, which I use via SSH. Sometimes the SSH typing takes about 5s and more to respond with an visual feedback after a time of idleness, after that lag everything just works fine.

(I started typing the moment the gif starts.)

I know the Raspberry Pi is no super modern MacBook Pro, but it's still kind of strange. I checked the connection, and checked my terminal setting, tried reconnecting with the pi and checked if other servers I use respond similar, but everything works fine with other servers. Could anybody tell me if they have the same problem and if so how to solve it?


It seems the OP has already found the solution. This answer is for future reference.

The OP's comment:

It turned out to be ClientAliveInterval of the openSSH server. That solved it.

The comment gives no further details. Fortunately quick Google search led to a post on www.raspberrypi.org:

by TimKaechele » Mon Sep 01, 2014

You can solve the problem in two ways:

  • setting the ServerAliveInterval to a number of seconds less than the time it takes to time out the connection,
  • or by configuring the SSH server's ClientAliveInterval (same process).

Is your PI running the stock raspbian image? If not please check following things:

  • Is your PI under heavy load? Check with uptime.

05:06:50 up 7 days, 17:49, 1 user, load average: 0.00, 0.01, 0.05

  • Does the PI behaves the same if you log in locally using monitor / keyboard.
  • Does the PI behaves the same if you use another machine to ssh from?
  • Is your network under heavy load and running slow?

Your problem seems to be unrelated to coding in general. Maybe ask this question in another community like Super User

  • 1
    It turned out to be be ClientAliveInterval of the openSSH server. That solved it. Thanks for the advise to another community, I didn't know that, I am deeply sorry. It will not happen again. – TimKaechele Sep 6 '14 at 7:21

I also suffered this issue for about a week until i finally figure out this is not caused by any setting of any config files. The true reason cause this laggy SSH connection is due to Raspberry Pi's poor BCM2837/43438 WiFi Bluetooth chip design , they share single antenna.

So please check if you have any Bluetooth device paired with your pi, even those device are powered OFF, remove all of them form paired device list, then your SSH is back to normal.


I encountered the same issue with Fedora Server 33 on a Raspberry Pi 4, the symptoms were :

  • Laggy SSH connection after leaving it untouched just a few seconds (just like the video above)
  • Pings to another host were all over the place, ranging from 20ms to 300ms

It was caused by the power management of the Wifi card. After disabling it everything went back to normal :

# Raspberry Pi OS arm64
iwconfig wlan0 power off

# Fedora 33
mcli connection modify wlan0 wifi.powersave disable

More reference on how to disable Wifi power management depending on your setup : https://askubuntu.com/questions/695867/disable-wifi-power-management


I had a different issue on the RPi 3, with the same symptoms. Here is the source for the solution.

In summary, some routers seem to have issues with new versions of SSH using a different value for IPQoS by default (mine seems to be a notoriously bad router + modem combo, so I'm not surprised). To fix this, add IPQoS 0x00 to sshd_config and ssh_config


In my case, uncommenting the following line in /etc/ssh/sshd_config did the trick for me, and my ssh session were not slow anymore afterwards:

UseDNS no

Don't forget to restart the ssh service after doing so:

service ssh restart
  • This will fix a lag at the initial SSH connection (when the server cannot contact its DNS server to get the reverse DNS of the IP opening a connection), it would not explain a lag on a running session. – Ugo Méda Jan 18 at 22:47

Your Answer

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