机制

ssh连贯的时候触发/etc/pam.d/login, 运行其中的**motd**设置, 将/etc/update-motd.d/目录下的脚本全副运行一遍

pam.d

(Pluggable Authentication Modules) 可动静加载验证模块.

Linux下PAM模块学习总结

简略说就是在/etc/pam.d/ 门路下能够搁置一个验证模块, 须要的服务就能够调用, 验证模块的文件名就是service的名称.

ssh login的时候调用了 /etc/pam.d/login, 其中上面的局部调用了Motd.

# Prints the message of the day upon successful login.# (Replaces the `MOTD_FILE' option in login.defs)# 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.dynamicsession    optional   pam_motd.so noupdate

Motd (message of today)

今日音讯板块, 提供欢送页面的各种信息. 门路为 /etc/update-motd.d/, login时门路下的每一个脚本都被运行一遍.

/etc/update-motd.d# ls00-header     50-landscape-sysinfo  85-fwupd         90-updates-available       91-release-upgrade      95-hwe-eol      98-fsck-at-reboot10-help-text  50-motd-news          88-esm-announce  91-contract-ua-esm-status  92-unattended-upgrades  97-overlayroot  98-reboot-required

批改, 或增加脚本就可批改Welcome Message

也能够创立一个 /etc/motd 文件, 外头填写想要显示的信息. 这个文件的内容将显示在所有下面脚本的最初.

集体案例

在腾讯云购买的服务器装置的Ubuntu, 进入时显示欢送音讯, 但却没有更新包的提醒. 运行 apt list —upgradable 却有很多能够更新的包. 查看当前发现 /etc/update-motd.d/ 门路下短少90号脚本 90-updates-available, 从其余服务器复制过去增加可运行权限当前更新包音讯就呈现了.

不显示Welcome Message

如果不想要显示任何欢送音讯的话, 除了更改下面的脚本, 还有一个办法. 就是在账号目录下创立一个空白的 .hushlogin

~: touch .hushlogin

连贯

Where does the "n packages can be upgraded" message come from

Show packages to be upgraded on login

Linux下PAM模块学习总结