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?

6
  • This should be migrated over to the "ask Ubuntu" folks, as it's quite specific.
    – Roman
    Feb 21, 2013 at 15:59
  • We can't migrate stuff from SF to askubuntu.com Feb 21, 2013 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, 2013 at 16:06
  • 1
    Check your shell start-up scripts, both global and user-specific.
    – Chris S
    Feb 21, 2013 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/. Feb 21, 2013 at 16:24

4 Answers 4

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.

4
  • PAM is out of the question. '-bash: cd: /etc/pam: No such file or directory' Feb 21, 2013 at 19:48
  • @SamvanKampen Sorry, /etc/pam.d/.
    – mgorven
    Feb 21, 2013 at 19:49
  • 1
    Ah, I should've checked for that. Feb 21, 2013 at 19:49
  • I think this is it, doing cat * | grep motd in pam.d reveals that line. I'll try commenting that and logging in again, if it works, I'll accept your answer :) Feb 21, 2013 at 19:54
2

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
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.

1
  • Following the above, you can do sudo service ssh restart and you should see just one Motd on login.
    – AndyC
    Feb 1, 2016 at 19:30
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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .