大网数据广告活动
服务器运维问答

There are two MOTD's shown when I login to my server using SSH

· 52CE 我爱测

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 …

问题原文

原帖链接 · Sam van Kampen · CC BY-SA 3.0

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?

已采纳解答

原帖链接 · mgorven · CC BY-SA 3.0

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.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2013-02-21)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。