I have two servers running Ubuntu 22.04.4 LTS. One of them (let's call it host1) I will be greeted with the motd upon logging in via SSH as shown below. However, on the second one (host2) this will not show on SSH login and I only get the "Last login" info.
Welcome to Ubuntu 22.04.4 LTS (GNU/Linux 5.15.0-112-generic x86_64)
* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/pro
System information as of So 16. Jun 15:00:05 CEST 2024
System load: 0.62 Processes: 115
Usage of /: 39.5% of 19.51GB Users logged in: 1
Memory usage: 58% IPv4 address for ens3: XXX.XXX.XX.XX
Swap usage: 0%
* Strictly confined Kubernetes makes edge and IoT secure. Learn how MicroK8s
just raised the bar for easy, resilient and secure K8s cluster deployment.
https://ubuntu.com/engage/secure-kubernetes-at-the-edge
Expanded Security Maintenance for Applications is enabled.
0 updates can be applied immediately.
Last login: Sat Jun 15 14:07:55 2024 from XXX.XXX.XXX.XXX
When I execute run-parts /etc/update-motd.d/
on either of them, it shows the expected info in both cases.
Running ls -l /etc/update-motd.d/
shows the files to be present and executable on both machines.
host1 (motd working as expected on login)
user@host1:~$ ls -l /etc/update-motd.d/
total 56
-rwxr-xr-x 1 root root 1220 Okt 15 2021 00-header
-rwxr-xr-x 1 root root 1151 Jan 2 15:57 10-help-text
lrwxrwxrwx 1 root root 46 Mai 6 22:11 50-landscape-sysinfo -> /usr/share/landscape/landscape-sysinfo.wrapper
-rwxr-xr-x 1 root root 5023 Okt 15 2021 50-motd-news
-rwxr-xr-x 1 root root 84 Mai 17 2023 85-fwupd
-rwxr-xr-x 1 root root 218 Feb 28 2023 90-updates-available
-rwxr-xr-x 1 root root 296 Nov 30 2023 91-contract-ua-esm-status
-rwxr-xr-x 1 root root 558 Jan 9 2023 91-release-upgrade
-rwxr-xr-x 1 root root 165 Feb 19 2021 92-unattended-upgrades
-rwxr-xr-x 1 root root 379 Feb 28 2023 95-hwe-eol
-rwxr-xr-x 1 root root 111 Aug 17 2020 97-overlayroot
-rwxr-xr-x 1 root root 142 Feb 28 2023 98-fsck-at-reboot
-rwxr-xr-x 1 root root 144 Feb 28 2023 98-reboot-required
-rwxr-xr-x 1 root root 275 Jun 15 03:05 99-livepatch-kernel-upgrade-required
host2 (motd not showing on login)
user@host2:~$ ls -l /etc/update-motd.d/
total 56
-rwxr-xr-x 1 root root 1220 Oct 15 2021 00-header
-rwxr-xr-x 1 root root 1151 Jan 2 14:57 10-help-text
lrwxrwxrwx 1 root root 46 May 6 20:40 50-landscape-sysinfo -> /usr/share/landscape/landscape-sysinfo.wrapper
-rwxr-xr-x 1 root root 5023 Oct 15 2021 50-motd-news
-rwxr-xr-x 1 root root 84 May 17 2023 85-fwupd
-rwxr-xr-x 1 root root 218 Feb 28 2023 90-updates-available
-rwxr-xr-x 1 root root 296 Nov 30 2023 91-contract-ua-esm-status
-rwxr-xr-x 1 root root 558 Jan 9 2023 91-release-upgrade
-rwxr-xr-x 1 root root 165 Feb 19 2021 92-unattended-upgrades
-rwxr-xr-x 1 root root 379 Feb 28 2023 95-hwe-eol
-rwxr-xr-x 1 root root 111 Aug 17 2020 97-overlayroot
-rwxr-xr-x 1 root root 142 Feb 28 2023 98-fsck-at-reboot
-rwxr-xr-x 1 root root 144 Feb 28 2023 98-reboot-required
-rwxr-xr-x 1 root root 275 Jun 12 02:08 99-livepatch-kernel-upgrade-required
It is unclear to me why the behavior is different on these two systems. I'm suspecting I might be missing something trivial here.
How can I get motd to show on SSH login? Does it have to be explicitly enabled somewhere?
By the way, I noticed that PrintMotd is set to 'no' in /etc/ssh/sshd_config
on both systems. Not sure if this is relevant at all, as host1 is displaying it despite being set to 'no'.
I do not have any custom motd scripts on either of these.
One bit of context that could explain a difference in configuration: host1 was set up via an Ubuntu 22.04 image from the cloud provider. host2 was set up using the standard 22.04 installation ISO from Ubuntu.com.
session optional pam_motd.so motd=/run/motd.dynamic
in the /etc/pam.d/sshd file? or onlysession optional pam_motd.so noupdate
?session optional pam_motd.so motd=/run/motd.dynamic
session optional pam_motd.so noupdate
UsePAM
set toyes
in both /etc/ssh/sshd_config files (or as confirmed by testing the configs withsudo sshd -T | grep -i pam
for example)UsePAM
was set tono
on host2. After setting it toyes
and reloading SSH, motd is now displayed on login. Many thanks! Though I'm not entirely sure I understand why this solved it. I always thought PAM was about authentication.