Subject: dynamic-motd: Makes SSH login horribly slow, even if MOTD isn't shown
Date: Fri, 10 Jun 2022 03:07:05 +0200
Package: dynamic-motd
Version: 0.04-1
Severity: normal
Before installing dynamic-motd, (key-based) "ssh root@localhost" was
more or less instantaneous (below 1 second).
Since installing dynamic-motd it takes about 40 seconds to login on that
box, even via localhost and even despite being a not so slow box (a
quad-core workstation with a single X session and lot of xterms and
outgoing SSH sessions):
~ → lscpu | fgrep "Model name"; uptime; date; ssh localhost date
Model name: Intel(R) Core(TM) i7-6700T CPU @ 2.80GHz
02:34:23 up 55 days, 7:39, 196 users, load average: 3.09, 3.52, 3.28
Fri Jun 10 02:34:23 CEST 2022
Fri Jun 10 02:35:05 CEST 2022
~ →
Most time seems to be spent for calling checkrestart (33 seconds). If
only needrestart would have been installed, that step would even have
taken even longer (4 minutes and 18 seconds; phew!)
So please try to at least cache the results of checkrestart and
needrestart. Or maybe pre-calculate them via cron-job once an hour or
so. Or disable them completely by default.
For those suffering from this issue as well, here's how I solved it for
myself:
# dpkg-divert --local --rename --divert /etc/update-motd.d/50-services-need-restart.DISABLED --add /etc/update-motd.d/50-services-need-restart
Now I'm down to about 8 seconds for logging in via SSH.
-- System Information:
Debian Release: bookworm/sid
APT prefers unstable
APT policy: (990, 'unstable'), (600, 'testing'), (500, 'unstable-debug'), (500, 'buildd-unstable'), (110, 'experimental'), (1, 'experimental-debug'), (1, 'buildd-experimental')
Architecture: amd64 (x86_64)
Foreign Architectures: i386
Kernel: Linux 5.16.0-6-amd64 (SMP w/8 CPU threads; PREEMPT)
Locale: LANG=C.UTF-8, LC_CTYPE=C.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /bin/dash
Init: sysvinit (via /sbin/init)
LSM: AppArmor: enabled
Versions of packages dynamic-motd depends on:
ii bc 1.07.1-3+b1
ii figlet 2.2.5-3+b1
ii lsb-release 11.2
ii python3 3.10.4-1+b1
ii python3-utmp 0.9-1+b5
dynamic-motd recommends no packages.
dynamic-motd suggests no packages.
-- no debconf information