Skip to content

feat(motd): add Chinese SSH last-login line with approved palette - #106

Merged
LucaLin233 merged 2 commits into
mainfrom
forge/feat-motd-login-palette
Nov 30, 2026
Merged

LucaLin233 merged 2 commits into
mainfrom
forge/feat-motd-login-palette

Conversation

@LucaLin233

Copy link
Copy Markdown
Owner

Summary

  • Adopt the approved log palette in the welcome panel: host #47DCC8, OS #FF8E9E (bold, no green dot), uptime number #6DFFBB with unit #BAC2DE, CPU #FFB86C, load #24F0D0, healthy memory/root disk #50FA7B, kernel #FF934D bold, architecture #A3B2C4, labels #A8B5D9.
  • Keep the existing narrow-terminal wrapping, NO_COLOR / TERM=dumb behaviour, and the CPU/load/memory/disk layout; the plain-text output is byte-identical after stripping colour.
  • Add a Chinese 上次登录 footer rendered by the same payload through an explicit --last-login mode. run-parts (no argument) still emits only the welcome panel, so no login record ever lands in the shared /run/motd.dynamic.
  • The footer is produced by session optional pam_exec.so type=open_session stdout quiet inserted directly after the last pam_motd.so line, which by OpenSSH ordering runs before the PTY record_login of the current session; the previous record is read with lslogins (modern --lastlog-file/--lastlog2-file, legacy --lastlog fallback) and the current connection is never used.
  • A single managed drop-in 60-linux-setup-last-login.conf sets PrintLastLog no. English is only suppressed after sshd -t and sshd -T confirm usepam yes and printlastlog no, and after the active ssh/sshd service reloads successfully; any failure rolls the disk back.
  • Restore rewrites the English drop-in and reloads before removing the PAM marker line, retries if the reload fails, and only strips this tool's own marker lines, so administrator edits made after install survive.

Scope

tools/setup-motd.sh, modules/system-customize.sh (identical payload and hook logic), tests/test-motd.sh. No change to shell prompt, background, accounts, or services at build time.

Validation

  • bash -n passes for both entrypoints and the test script; git diff --check is clean.
  • Payloads extracted from both entrypoints are byte-identical and match the pinned SHA-256.
  • Targeted synthetic fixtures cover IPv4/IPv6/hostname/absent source/absent history, missing lslogins, unsupported util-linux, administrator PAM pam_exec, administrator drop-in, sshd -t failure, printlastlog unconfirmed, UsePAM no, reload failure on install and on restore, idempotent re-install, post-install administrator edits, and legacy snapshots without hook state.
  • Full regression is delegated to CI on this PR.

Risks

  • Depends on pam_exec and the PAM pam_motd anchor; without them the tool keeps the original English line.
  • The reload only touches the already-active ssh.service/sshd.service; socket-activated listeners are not restarted.

Rollback

The MOTD restore path removes the drop-in and reloads the English message before removing the PAM line. Manually, delete 60-linux-setup-last-login.conf, drop the # linux-setup:last-login-hook line from /etc/pam.d/sshd, and systemctl reload ssh.

FORGE added 2 commits December 1, 2026 06:22
Adopt the approved log palette for the welcome panel (host, OS, uptime,
load, kernel, architecture, labels; drop the green status dot) and add a
Chinese "last login" footer rendered by the same payload in an explicit
--last-login mode.

The footer is emitted by an optional pam_exec(open_session) hook that runs
right after pam_motd, so it reads the previous record before OpenSSH writes
the current session. A single managed sshd drop-in sets PrintLastLog no so
the English line is replaced, and English is only suppressed after
sshd -t/-T confirm UsePAM yes and PrintLastLog no; the active ssh service is
reloaded, with rollback on failure. Restore rewrites the English drop-in and
reloads before removing the PAM hook, and only strips the tool's own marker
lines so later administrator edits survive.
@LucaLin233
LucaLin233 merged commit 7205cb4 into main Nov 30, 2026
16 checks passed
@LucaLin233
LucaLin233 deleted the forge/feat-motd-login-palette branch November 30, 2026 22:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant