3

I'm having trouble getting any output when logging in via SSH.

I removed all scripts under /etc/update-motd.d/ and I installed my own bash scripts.

Before

➜  ~ ls -la /etc/update-motd.d/
total 64
drwxr-xr-x   2 root root 4096 Apr 19 19:34 .
drwxr-xr-x 106 root root 4096 Apr 24 11:41 ..
-rwxr-xr-x   1 root root 1220 Dec  5  2019 00-header
-rwxr-xr-x   1 root root 1157 Dec  5  2019 10-help-text
lrwxrwxrwx   1 root root   46 Apr 19 19:34 50-landscape-sysinfo -> /usr/share/landscape/landscape-sysinfo.wrapper
-rwxr-xr-x   1 root root 5023 Aug 17  2020 50-motd-news
-rwxr-xr-x   1 root root   84 Feb 21 03:06 85-fwupd
-rwxr-xr-x   1 root root  106 Apr 29  2021 88-esm-announce
-rwxr-xr-x   1 root root  218 May 14  2021 90-updates-available
-rwxr-xr-x   1 root root  112 Apr 29  2021 91-contract-ua-esm-status
-rwxr-xr-x   1 root root  374 Apr 14 17:21 91-release-upgrade
-rwxr-xr-x   1 root root  165 Jul 21  2020 92-unattended-upgrades
-rwxr-xr-x   1 root root  129 May 14  2021 95-hwe-eol
-rwxr-xr-x   1 root root  111 Nov  2 14:33 97-overlayroot
-rwxr-xr-x   1 root root  142 May 14  2021 98-fsck-at-reboot
-rwxr-xr-x   1 root root  144 May 14  2021 98-reboot-required

After

➜  ~ ls -la /etc/update-motd.d/
total 28
drwxr-xr-x   2 root root 4096 Apr 24 11:45 .
drwxr-xr-x 106 root root 4096 Apr 24 11:48 ..
-rwxr-xr-x   1 root root  146 Apr 24 11:45 .common.sh
-rwxr-xr-x   1 root root  152 Apr 24 11:45 00-daze-banner
-rwxr-xr-x   1 root root  294 Apr 24 11:45 10-security-warning
-rwxr-xr-x   1 root root  414 Apr 24 11:45 50-ubuntu-flavour
-rwxr-xr-x   1 root root 1313 Apr 24 11:45 90-sys-info

This is what is in my /etc/pam.d/{login,sshd} files:

➜  ~ grep "motd" /etc/pam.d/login
session    optional   pam_motd.so motd=/run/motd.dynamic.new
#session    optional   pam_motd.so noupdate
➜  ~ grep "motd" /etc/pam.d/sshd 
session    optional     pam_motd.so  motd=/run/motd.dynamic.new
#session    optional     pam_motd.so noupdate

And in my /etc/ssh/sshd_config file I have the PrintMotd Yes option.

I think the problem is that the /run/motd.dynamic.new file never gets updated and is always empty:

➜  ~ wc /run/motd.dynamic.new
0 0 0 /run/motd.dynamic.new

Running sudo run-parts /etc/update-motd.d/ produces the expected output.

  • Can you tell me what's wrong?
  • How can I debug it?

Note

In the scripts I'm using some utilities like lolcat, boxes and figlet to make text look like this:

ssh login expected output

  • You can run this command to see if there are any errors in the scripts: sudo run-parts /etc/update-motd.d/. – Michal Przybylowicz Apr 24 '22 at 13:19
  • I already ran that command as I specified in the question and the output is what you see in the image attached. – kungfubamba Apr 24 '22 at 13:42
  • I'm running Ubuntu 22.04 and have a custom script in there, but /run/motd.dynamic.new doesn't exist. – TommyPeanuts Jun 25 '22 at 08:54
  • @kungfubamba this question helped me to see the problem: https://askubuntu.com/questions/1207493/unit-systemd-resolved-service-is-masked – MacMartin Dec 20 '22 at 16:26
  • MacMartin perhaps you'd like to submit an answer to the motd question with the insight gained from the related linked answer. – jorfus Sep 11 '23 at 17:01

0 Answers0