当我使用SSHlogin到我的服务器时,显示了两个MOTD

我想要改变在TTY上login到计算机时显示的MOTD,这看起来可行,但不知何故,它不仅仅在/etc/motd/etc/update-motd.d/显示MOTD ,但也是另一个讯息。

当我login到我的服务器时显示:

 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>:~$ 

我的update-motd.d包含两个文件, 00-header10-help-text

00-header包含以下内容:

 [ -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)" 

10-help-text包含这个:

 [ -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" 

这将弥补MOTD的部分,直到No mail. 。 但其余的来自哪里呢?

MOTD可以通过sshd或PAM打印。 有可能两个都在做。

检查你的/etc/ssh/sshd_config以下内容:

 PrintMotd yes 

如果该行不存在,则可能默认为yes (尽pipeDebian / Ubuntu将默认值更改为no )。

/etc/pam.d/检查您的PAMconfiguration以获取以下信息:

 session optional pam_motd.so 

尝试一次禁用这些,看看有什么变化。

如果您使用的是Ubuntu,您可以尝试:

 sudo nano /etc/ssh/sshd_config 

并查看PrintMotdUsePam都设置为true,这是我的情况。

注意 :如上所述,你可以做sudo service ssh restart ,你应该只能看到一个motdlogin。

经过Debian 8testing之后:

这是/etc/pam.d/login中的这个选项打印另一个motd

 session optional pam_exec.so type=open_session stdout /bin/uname -snrvm