Modifying the login text on Debian (or Ubuntu)

I’m getting back into the Debian world after years of being pretty much a RHEL guy and I’ve bee dealing with an annoying “feature” which I was at a loss to resolve. Every time I log into the EC2 instance that this server runs on, I get a “No mail.” message which clutters up my login scripts and shouldn’t be there since I’m not receiving mail on this instance in the first place.

Today I finally decided I’d get to the bottom of it since it clearly wasn’t coming from a login script and even though it’s a minor thing it bugs me and I find it somewhat distracting!

It turns out that Debian and it’s derivatives have what is a rather elegant, if initially opaque, way of setting up the login info: it’s managed in a PAM module for the SSHD which can be found at /etc/pam.d/sshd.

Not only does PAM load a module that checks mail by default, it also does a couple of cool things with the MOTD info (this is where the kernel version info comes from when you login).

Here’s the relevant section:

# 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  motd=/run/motd.dynamic noupdate
session    optional # [1]

# Print the status of the user's mailbox upon successful login.
#session    optional standard noenv # [1]

As you can see I’ve commented out the mail check, I’ve decided to leave the MOTD piece, I think I’m going to play around with it.  It’s the first time I’ve ever encountered the pam_motd module and I’m curious what I can do with it.

Hopefully somebody else finds this helpful, there seems to be little information about this available when I did a quick Google search.