8

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?

Sam van Kampen
  • 183
  • 1
  • 1
  • 5
  • This should be migrated over to the "ask Ubuntu" folks, as it's quite specific. – Roman Feb 21 '13 at 15:59
  • We can't migrate stuff from SF to askubuntu.com – ThatGraemeGuy Feb 21 '13 at 16:05
  • @GraemeDonaldson Moderators can if they feel it's necessary and a user flags it for their attention. That said, it seems like it's probably fine here as well. If subject matter overlaps between sites, the rule has been to leave it where it was asked. – MDMarra Feb 21 '13 at 16:06
  • 1
    Check your shell start-up scripts, both global and user-specific. – Chris S Feb 21 '13 at 16:12
  • It is not in /etc/profile, ~/.bashrc or ~/.profile and there is no ~/.bash_profile. There is nothing in /etc/profile.d/. – Sam van Kampen Feb 21 '13 at 16:24
  • @MDMarra Oh cool, I didn't realise mods can migrate to sites not in the normal list. – ThatGraemeGuy Feb 22 '13 at 07:40

4 Answers4

14

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.

mgorven
  • 30,036
  • 7
  • 76
  • 121
1

If you are using Ubuntu, you might try to:

sudo nano /etc/ssh/sshd_config

and check to see of PrintMotd and UsePam are both set to true, that was the case for me.

Note: Following the above, you can do sudo service ssh restart and you should see just one Motd on login.

Jakuje
  • 9,145
  • 2
  • 40
  • 44
AndyC
  • 11
  • 2
  • Following the above, you can do sudo service ssh restart and you should see just one Motd on login. – AndyC Feb 01 '16 at 19:30
0

On Ubuntu 22.04 server, I had this happen by installing the update-motd package. Uninstalling it did not help.

It seems the pam at-login-time dynamic functionality creates /run/motd.dynamic and update-motd creates /run/motd, and then both gets printed at ssh login.

The solution for me was to uninstall update-motd and remove /run/motd:

sudo apt remove --purge update-motd
sudo rm -f /run/motd
0

After testing on Debian 8:

It is this option in /etc/pam.d/login prints another motd

session    optional   pam_exec.so type=open_session stdout /bin/uname -snrvm
PokerFace
  • 161
  • 1
  • 4