Ubuntu has been using
update-motd as a MOTD (Message of the Day) generator for several years. Some of the default messages — such as the number of available security patches — can be helpful, but not everyone likes being greeted by a barrage of text every time they log in to their server. In this article, we’ll explore how to adjust, disable, or replace the dynamic MOTD in Ubuntu.
Before You Begin
If you’d rather work with
update-motd than turn it off, detailed documentation for changing its output is available in the man page for update-motd. Essentially, the dynamic MOTD is generated by a collection of executable scripts found in the
/etc/update-motd.d/ directory. These scripts can be updated, removed, or reordered, and new scripts can be added.
Disabling the Dynamic MOTD
While Ubuntu does not provide a way to directly uninstall
update-motd, it is possible to disable it by adjusting a few PAM options. Two lines, found in both
/etc/pam.d/sshd, control how
update-motd runs on login:
session optional pam_motd.so motd=/run/motd.dynamic session optional pam_motd.so noupdate
Commenting out those lines in both files will prevent the
pam_motd.so module from being loaded and will completely disable the dynamic MOTD.
Bonus Section: Enabling a Static MOTD
If you still want a message printed when you log in via SSH, you can configure OpenSSH to display a traditional static MOTD. From the man page for sshd_config:
Specifies whether sshd should print /etc/motd when a user logs in interactively. (On some systems it is also printed by the shell, /etc/profile, or equivalent.) The default is “yes”.
Ubuntu disables this option by default and incorporates
/etc/motd into its dynamic generator, but we can re-enable the option to make
/etc/motd work again. Add or uncomment the following line in
/etc/ssh/sshd_config and restart the OpenSSH daemon to have OpenSSH print
/etc/motd on login: