pam_motd

最後更新: 2023-05-03

介紹

After a successful login, by default the /etc/motd file is shown.

The message size is limited to 64KB

目錄

  • pam_motd.so
  • ssh pam settings
  • update-motd

pam_motd.so - Display the motd file

 

Usage

pam_motd.so [motd=/path/filename]                  # Default: /etc/motd

Debiang / Ubuntu

* Run the scripts from /etc/update-motd.d to update the motd on login

i.e.

# A static (admin-editable) motd

session    optional     pam_motd.so

# Dynamically generated motd

session    optional     pam_motd.so  motd=/run/motd.dynamic noupdate

noupdate     -      Don't run the scripts in /etc/update-motd.d to refresh the motd file.

 


ssh pam settings

 

motd

它有分 Dynamically / Statically

  • Dynamically generated part from /run/motd.dynamic
  • A statically (admin-editable) part from "/etc/motd"

/etc/pam.d/sshd

session    optional     pam_motd.so  motd=/run/motd.dynamic
session    optional     pam_motd.so  noupdate

P.S. 

By default the /etc/motd file is shown

session  optional  pam_motd.so

相當於

session  optional  pam_motd.so  motd=/etc/motd

Disable motd in pam

sed -i '/^[^#]*\<pam_motd.so\>/s/^/#/' /etc/pam.d/sshd

 


update-motd

 

Package: update-motd    # apt install update-motd

update-motd 是 shell script

它會 run-parts /etc/update-motd.d 並輸出到 stdout

ls -1 /etc/update-motd.d    # U22

  • 00-header
  • 10-help-text
  • ...
  • 98-fsck-at-reboot
  • 98-reboot-required

 

Creative Commons license icon Creative Commons license icon