Answers:
欢迎消息是由中的文件生成的/etc/update-motd.d/
。
来自man update-motd
:
/etc/update-motd.d/*中的可执行脚本由pam_motd(8)作为root用户在每次登录时执行,并且此信息串联在/ var / run / motd中。
因此,如果您不希望通过登录ssh
删除这些脚本的输出,只需删除它们上的execute标志:
sudo chmod -x /etc/update-motd.d/*
现在,如果您想在登录时显示想要的内容,则有两个选择:
创建一个脚本,将其放入中/etc/update-motd.d/
,使其可执行,还确保其在STDOUT上输出。
ssh
有一个Banner
选择。您可以将文本放在文件中,然后在Banner
选项中进行设置,以便在通过登录时显示文件的内容ssh
。请注意,这仅适用于ssh
。
Banner /etc/foobar
来自man 5 sshd_config
:
Banner The contents of the specified file are sent to the remote user
before authentication is allowed. If the argument is “none” then
no banner is displayed. This option is only available for
protocol version 2. By default, no banner is displayed.
chmoding
文件意味着我不必编辑它们。真好!
您也可以pam_motd
完全核对:
sed -i '/^[^#]*\<pam_motd.so\>/s/^/#/' /etc/pam.d/sshd
PAM呼叫pam_motd
取决于中的设置/etc/pam.d
,通常,这些条目是:
$ grep pam_motd /etc/pam.d -R
/etc/pam.d/login:session optional pam_motd.so motd=/run/motd.dynamic noupdate
/etc/pam.d/login:session optional pam_motd.so
/etc/pam.d/sshd:session optional pam_motd.so motd=/run/motd.dynamic noupdate
/etc/pam.d/sshd:session optional pam_motd.so # [1]
仅注释掉pam_motd
这些文件中的行会禁用它。
pam_motd.so
,仅此而已。
不需要管理权限的另一种方法是放置一个名为
.hushlogin
进入您的$ HOME目录(例如touch ~/.hushlogin
)。
提供更多信息的资源,包括此方法的可能缺点:https : //debian-administration.org/article/546/Giving_yourself_a_quieter_SSH_login
sudo
。谢谢。