Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

update-motd.d scripts not running

I have created a test script below to add to /etc/update-motd.d/05-lsb-release

#!/bin/sh
echo
lsb_release -a

but when i have rebooted the machine, restarted SSH and connected to it through SSH i am not seeing the changes applied

Welcome to Ubuntu 14.04.5 LTS (GNU/Linux 3.13.0-105-generic x86_64)

0 packages can be updated. 0 updates are security updates. 

Last login: Sun Dec 11 17:08:40 2016 from xxx.xxx.xxx.xxx
paul@ubuntu1404:~$

the output in /var/run/update-motd.dynamic is the same as above, however /var/run/update-motd.dynamic.new shows the correct information

Welcome to Ubuntu 14.04.5 LTS (GNU/Linux 3.13.0-105-generic x86_64)

Distributor ID: Ubuntu
Description:    Ubuntu 14.04.5 LTS
Release:        14.04
Codename:       trusty

0 packages can be updated.
0 updates are security updates.

how can i see the changes when i log in?

I am running the latest updates to Ubuntu 14.04.5 LTS

like image 228
Paul Goggin Avatar asked Dec 11 '16 17:12

Paul Goggin


3 Answers

You might have an error in your motd script. Check it with:

run-parts /etc/update-motd.d/ > /dev/null

Should this command report errors you need to fix them.

like image 53
reto Avatar answered Sep 19 '22 18:09

reto


It is configured in the PAM. Have a look into the file /etc/pam.d/sshd. There is a line such as

session    optional     pam_motd.so noupdate

which prevents dynamic updates when logging in (your "dynamic" MoTD is quite static, so it does not make sense to update it with every login, isn't it?).

More described in the AskUbuntu.

like image 43
Jakuje Avatar answered Sep 17 '22 18:09

Jakuje


Test your motd like the (ubuntu? maybe debian too?) system does

/usr/bin/env -i PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin run-parts --lsbsysinit /etc/update-motd.d

(taken from this blog https://ownyourbits.com/2017/04/05/customize-your-motd-login-message-in-debian-and-ubuntu/)

in my case, lolcat was dying on utf8 chars because it was being launched with an ASCII as its language, fixed by prefixing the lolcal invocation with LANG=en_US.UTF-8 lolcat ...

like image 23
ThorSummoner Avatar answered Sep 21 '22 18:09

ThorSummoner