It sounds like you are saying the `/etc/issue` file is supposed to auto-update when the `/etc/hosts` file is modified.
Well, it does, but only once on boot up.
What can I do to have this happen automatically upon editing the `/etc/hosts` file?
You could do that by creating a systemd path unit and overriding the
RemainAfterExit
of the
pvebanner.service
to
no
, e.g.:
cat /usr/local/lib/systemd/system/pvebanner.path
Code:
[Path]
PathModified=/etc/hosts
[Install]
WantedBy=multi-user.target
(file name is important)
Then override the banner service
systemctl edit pvebanner.service
An editor opens, there add:
Code:
[Service]
RemainAfterExit=no
Save and stop the old pvebanner service once:
systemctl stop pvebanner.service
Then enable and start that the path service
systemctl enable --now pvebanner.path
Test editing /etct/hosts and check with
systemctl status pvebanner.service
if it actually started afterwards.
Using something like inotify-watch could be a different option.
Additionally, I would like to add the `Last login:` line to the `/etc/issue` file so it shows on login for physical access as well as remote access (see Tmanok's first screenshot for examples of how ssh/remote and physical terminal banners are different).
That isn't normally done by
/etc/issue
, as that always shows up already before an actual login happened to anybody, and also isn't refreshed once after the console outputted it (iow. started).
The line from the screenshot comes actually from PAM, namely the
pam_lastlog.so
that's by default enabled in
/etc/pam.d/login
(I heavily recommend against messing with PAM config if unsure!).
You could use
/etc/motd
(message of the day), as that is displayed after a successful login but just before it executes the login shell, but is constrained for static text.
On Debian based systems you normally got also the possibility to place shell scripts in
/etc/update-motd.d/
, which are executed on login displaying their output, for example, if you want to display the last 5 logins that happened you could do something like:
Code:
printf '#!/bin/sh\nlast -5\n' > /etc/update-motd.d/100-last-logins
chmod +x /etc/update-motd.d/100-last-logins