Signup/Sign In
Ask Question
Not satisfied by the Answer? Still looking for a better solution?

How to set a dynamic Message of the Day (motd) in Debian Jessie 8.2 for ssh?

I would like to have a dynamic motd, but I can't figure out how to do it.

I tried what I found, adding /etc/update-motd.d/00-header, 10-sysinfo, 90-footer, and symlinking to /etc/motd, /var/run/motd.dynamic, /run/motd.dynamic, /run/motd or /var/run/motd.
I've got these lines in /etc/pam.d/sshd:
# Print the message of the day upon successful login.
# This includes a dynamically generated part from /run/motd.dynamic
# and a static (admin-editable) part from /etc/motd.
session optional pam_motd.so motd=/run/motd.dynamic
session optional pam_motd.so noupdate


I'm also confused with systemd.

Is there a way to do this? Could someone provide a example with a simple fortune?
by

1 Answer

Kajalsi45d
So this is how things are currently: PAM will just read /var/run/motd.dynamic and /etc/motd if it exists (paste from post)

/etc/motd – The classic, static file. Does not exist anymore in Ubuntu 16.04 LTS, not even as a symbolic link to /var/run/motd. If it is created, however its contents will be printed too.
/var/run/motd – This was used by Ubuntu’s first implementation. It is not used anymore. It is just ignored by PAM.
/var/run/motd.dynamic – This is what is shown on login currently. It is updated by /etc/init.d/motd at every boot. It is also updated by PAM by running the scripts in /etc/update-motd.d/, if they exist.
/etc/motd.tail – The Ubuntu package used to populate /etc/update-motd.d. One of them would cat the contents of this file so it was easy to add static content. That script does not exist in the package anymore, so the file does not have the intended effect.

The example from the post
mkdir /etc/update-motd.d
rm -f /etc/motd # in Debian still exists
cat > /etc/update-motd.d/10logo <<EOF
#!/bin/sh
echo
cat /etc/issue
EOF

cat > /etc/update-motd.d/20updates <<'EOF'
#!/bin/sh
echo
echo "uptime is $( uptime )"
echo "date is $( date )"
EOF

chmod a+x /etc/update-motd.d/

Login / Signup to Answer the Question.