How to Disable the Dynamic MOTD in Ubuntu or Debian
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 straightforward way to remove
update-motd, it’s possible to disable it by adjusting a few PAM options. Two lines, found in both
update-motd to run on login:
session optional pam_motd.so motd=/run/motd.dynamic session optional pam_motd.so noupdate
Commenting out these lines in both files will prevent the
pam_motd.so module from being loaded and will disable the dynamic MOTD.
Bonus Section: Enabling a Static MOTD
If you still want a message printed to the console on login, you can fall back to a static MOTD. Per the man page for sshd_config, OpenSSH can easily be configured to display a static MOTD:
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: