Linux – There are two MOTD’s shown when I login to the server using SSH

linuxmotdUbuntu

I wanted to change the MOTD that is shown when you login to a computer on a TTY, which seems to work, but somehow, it doesn't just show the MOTD in /etc/motd and /etc/update-motd.d/, but also another message.

This is shown when I login to my server:

sam@laptop:~$ ssh <user>@<server>
Welcome to Ubuntu 12.04.2 LTS (GNU/Linux 2.6.32-042stab068.8 i686)

 * Documentation:  https://help.ubuntu.com/
No mail.
Last login: Thu Feb 21 19:20:55 2013 from <ip>
Welcome to Ubuntu 12.04.2 LTS (GNU/Linux 2.6.32-042stab068.8 i686)

 * Documentation:  https://help.ubuntu.com/

<user>@<server>:~$

My update-motd.d contains two files, 00-header and 10-help-text.

00-header contains the following:

[ -r /etc/lsb-release ] && . /etc/lsb-release

if [ -z "$DISTRIB_DESCRIPTION" ] && [ -x /usr/bin/lsb_release ]; then
        # Fall back to using the very slow lsb_release utility
        DISTRIB_DESCRIPTION=$(lsb_release -s -d)
fi

printf "Welcome to %s (%s %s %s)\n" "$DISTRIB_DESCRIPTION" "$(uname -o)" "$(uname -r)"     "$(uname -m)"

And 10-help-text contains this:

[ -r /etc/lsb-release ] && . /etc/lsb-release

if [ -z "$DISTRIB_RELEASE" ] && [ -x /usr/bin/lsb_release ]; then
    # Fall back to using the very slow lsb_release utility
    DISTRIB_RELEASE=$(lsb_release -sr)
fi

URL="https://help.ubuntu.com/"
if uname -r | grep -qs "\-server"; then
    URL="https://help.ubuntu.com/$DISTRIB_RELEASE/serverguide/C"
fi

printf "\n * Documentation:  %s\n" "$URL"

This would make up for the portion of the MOTD up until No mail.. But where is the rest coming from?

Best Answer

The MOTD can either be printed by sshd, or by PAM. It's possible that both are doing it.

Check your /etc/ssh/sshd_config for the following:

PrintMotd yes

If that line isn't present it may be defaulting to yes (although Debian/Ubuntu change the default to no).

Check your PAM configuration in /etc/pam.d/ for the following:

session    optional     pam_motd.so

Try disabling these one at a time to see what changes.