我可以在下面的Debian Jessie 8.2主机上测试带有财富示例的简单dynamic-motd,发现该问题与越野车行为有关。
mkdir /etc/update-motd.d
cd /etc/update-motd.d
如下创建两个测试文件并使它们可执行
root@debian:/# cd /etc/update-motd.d/
root@debian:/etc/update-motd.d# ls -l
total 8
-rwxr-xr-x 1 root root 58 Dec 1 23:21 00-header
-rwxr-xr-x 1 root root 41 Dec 1 22:52 90-fortune
root@debian:/etc/update-motd.d# cat 00-header
#!/bin/bash
echo
echo 'Welcome !! This is a header'
echo
root@debian:/etc/update-motd.d# cat 90-fortune
#!/bin/bash
echo
/usr/games/fortune
echo
但是,此时,motd没有任何变化。所以我跟踪了sshd进程。从该跟踪(如下所示的有趣部分)中,您可以看到新创建的motd.new文件被重命名为/ var / run / motd。但是,它稍后尝试读取/run/motd.dynamic-从未创建
20318 rename("/var/run/motd.new", "/var/run/motd") = 0
20318 open("/run/motd.dynamic", O_RDONLY) = -1 ENOENT (No such file or directory)
20318 open("/etc/motd", O_RDONLY) = 8
该问题似乎与pam_motd模块的不一致有关。查看错误报告https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=743286;msg=2
只需将motd文件位置从/run/motd.dynamic
更改/run/motd
为/etc/pam.d/sshd
-即可为我工作
root@debian:/etc/pam.d# grep pam_motd sshd
#session optional pam_motd.so motd=/run/motd.dynamic
session optional pam_motd.so motd=/run/motd
session optional pam_motd.so noupdate
这是在ssh登录期间看到的示例MOTD ...
Welcome !! This is a header
* Culus fears perl - the language with optional errors
The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
You have new mail.
Last login: Tue Dec 1 23:49:57 2015 from x.x.x.x
pam_motd.so noupdate
那里不是问题吗?