/etc/motd 在 Gentoo Linux 上打印两次

发布于 2024-07-06 15:49:55 字数 358 浏览 4 评论 0原文

我遇到了一个问题,我在 Gentoo Linux 上得到了 /etc/motd 文件的两个打印输出。 sshd 正在执行其中一份打印输出,我可以通过配置 /etc/ssh/sshd_config 来切换它,但我无法找出谁在打印第二份副本。 由于审计要求,我无法禁用 sshd 打印 motd。 我正在运行 bash shell,它的价值是什么

?谁在打印第二份副本? 我不认为这是 bash,因为当我更改 /etc/passwd 以使用 /bin/ksh 作为我的 shell 时,我仍然显示 motd。

它不是 /etc/issue,因为它包含字符串“This is \n (\s \m \r) (\l)”,只有当您坐在机器前面时才会打印该字符串。

I've run into a problem where I'm getting two printouts of my /etc/motd file on Gentoo Linux. sshd is doing one of the printouts, and I can toggle that by configuring /etc/ssh/sshd_config, but I can't find out who's printing the second copy. I can't disable sshd from printing out the motd due to an audit requirement. I'm running the bash shell, for what it's worth

Any ideas who's printing the second copy? I don't think it's bash, as when I change /etc/passwd to use /bin/ksh for my shell, I still get the motd displayed.

It's not /etc/issue, as that contains the string "This is \n (\s \m \r) (\l)", which is printed only when you're sitting in front of the machine.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(10

妥活 2024-07-13 15:49:55

看起来答案在 /etc/pam.d/login 和 /etc/pam.d/system-login 文件中。 我必须注释掉 pam_motd.so 行。

Looks like the answer was in the /etc/pam.d/login and /etc/pam.d/system-login files. I had to comment out the pam_motd.so lines.

铁轨上的流浪者 2024-07-13 15:49:55

您是否从 SSH 连接登录?.. 如果是这样,也许您必须在 sshd_config 文件上启用“PrintMotd No”键并将其设置为 no,然后重新启动服务...

Are you login from SSH connection??.. If so, maybe you must enable and set to no the key "PrintMotd No" on your sshd_config file and restart the service...

若无相欠,怎会相见 2024-07-13 15:49:55

我也遇到了这个问题,令我困扰的不是双 motd,而是双“上次登录”行,第二行引用了其上方的登录事件。

我认为这可能表明某种恶意行为,就好像我的登录被重定向或通过某些间谍软件或其他东西进行传输。

以下是我的 /etc/pam.d/system-login 的底部 5 行:

session         required        pam_env.so
#session        optional        pam_lastlog.so
session         include         system-auth
#session        optional        pam_motd.so motd=/etc/motd
session         optional        pam_mail.so

请注意注释掉的行。 现在一切都按预期进行。 谢谢,丹尼尔。

I had this problem too, and what was troubling to me was not the double-motd, it was the double "Last login" lines with the second referring back to the login event just above it.

I thought it might indicate foul play of some sort, as if my login were being re-directed or piped through some spyware or something.

Here is what the bottom 5 lines of my /etc/pam.d/system-login looks like:

session         required        pam_env.so
#session        optional        pam_lastlog.so
session         include         system-auth
#session        optional        pam_motd.so motd=/etc/motd
session         optional        pam_mail.so

Note the commented-out lines. Everything works as expected now. Thanks, Daniel.

不即不离 2024-07-13 15:49:55

我在 Ubuntu 15.04 和配置为使用 PAM 身份验证的 SSHD 上遇到了同样的问题。 我的服务器正在发送两个 MOTD。 我通过让 SSHD 在每次登录时刷新 MOTD 来使其正常工作。 这是通过编辑 /etc/pam.d/sshd 并删除/注释 noupdate 行来完成的。

# Print the message of the day upon successful login.
# This includes a dynamically generated part from /run/motd.dynamic
# and a static (admin-editable) part from /etc/motd.
session    optional     pam_motd.so  motd=/run/motd.dynamic
#session    optional     pam_motd.so  noupdate

缺点是,如果刷新此消息的过程需要一段时间(或 CPU 时间),则登录可能会浪费一些资源,看起来需要一段时间甚至超时。

然而,Ubuntu 15.04 中开箱即用的基本默认 MOTD 应该不会造成问题。

I had the same issue with Ubuntu 15.04 and SSHD configured to use PAM Authentication. My server was sending two MOTD. I managed to make it work nicely by letting SSHD refreshing the MOTD at each login. This is done by editing /etc/pam.d/sshd and removing/commenting the line which says noupdate.

# Print the message of the day upon successful login.
# This includes a dynamically generated part from /run/motd.dynamic
# and a static (admin-editable) part from /etc/motd.
session    optional     pam_motd.so  motd=/run/motd.dynamic
#session    optional     pam_motd.so  noupdate

The drawback is that if the process of refreshing this message takes a while (or CPU time) logging in could waste some resource, appear to take a while or even timeout.

However, the basic default MOTD as configured out of the box in Ubuntu 15.04 should not cause trouble.

羅雙樹 2024-07-13 15:49:55

另请检查 /etc/issue,某些系统会打印两者,并且它们可能只包含相同的文本。
请注意,我不使用 gentoo,所以情况可能并非如此。

Also check out /etc/issue, some systems print both and they might just contain the same text.
Note that I don't use gentoo so this might not be the case.

俏︾媚 2024-07-13 15:49:55

除了注释掉 pam_motd.so 行之外,不要忘记注释掉 /etc/pam.d/login 和 /etc/pam.d/system-login 中的以下行:

session 可选 pam_lastlog.so

像这样,“上次登录”行被打印一次而不是两次。

In addition to commenting out the pam_motd.so lines, don't forget to also comment out the following lines in /etc/pam.d/login and /etc/pam.d/system-login:

session optional pam_lastlog.so

Like this, the "last login" line gets printed once instead of twice.

你的笑 2024-07-13 15:49:55

我认为确保打印 MOTD 的唯一组件是 PAM 更有意义。 这样您就可以在其他地方禁用它,并且仍然符合您的审核要求。

只是我的 0.02 美元。

I think it would make more sense to make sure that the only component that prints MOTD is PAM. This way you can disable it everywhere else and still comply with your audit requirement.

Just my $0.02.

向日葵 2024-07-13 15:49:55

当我遇到这个问题时,我了解到这是系统发布给我时激活的设置组合。 该消息的第一个副本是在 SSH 身份验证发生之前打印的,这是由于在 sshd_config 中设置了 SSH 的 Banner 选项:对

Banner /etc/motd

MOTD 的误用不仅仅是对 横幅

打印该消息的第二个副本是因为在其默认配置中,SSH 在登录时打印 MOTD。 我通过设置 PrintMotd 来禁用它:

PrintMotd no

When I had this problem, I learned it was a combination of settings active when the system had been issued to me. The first copy of the message was printed before SSH authentication happened, and was due to SSH's Banner option being set in sshd_config:

Banner /etc/motd

A misuse of MOTD more than a misuse of Banner.

The second copy of the message was printed because in its default configuration, SSH prints the MOTD upon login. I disable that by setting PrintMotd:

PrintMotd no
仅此而已 2024-07-13 15:49:55

这可能是由 shell 本身完成的。 检查全局配置文件和 bashrc 以查看是否存在这种情况。

It is probably being done from the shell itself. Check the global profile and bashrc to see if this might be the case.

罪#恶を代价 2024-07-13 15:49:55

要仅允许 pam_motd.so 模块打印 motd,请将 /etc/login.defs 中的 MOTD 变量设置为空字符串。

MOTD_FILE“”

To allow only the pam_motd.so module to print the motd set the MOTD variable in /etc/login.defs to an empty string.

MOTD_FILE ""

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文