My working dynamic Linux MOTD displayed when accessing device by SSH or terminal directly. Primarily designed for Raspberry Pi.
Thanks to others for advice and MOTD examples, including:
- Gagle installation and MOTD samples https://github.com/gagle/raspberrypi-motd
Designed for and tested on Raspberry Pi 3 Model B Rev 1.2 (Linux 5.15.84-v8+ aarch64 GNU/Linux) (Debian 11 Bullseye) Written in pure Bash. No need to install any packages.
Loads in ~0.51s on the test platform listed in (Compatibility)[#Compatibility]. The script is blocking, so if that matters to you be careful what and how much you add to this :)
The following steps may vary depending on the OS. Debian 11 (Bullseye) is assumed.
Note: There are multiple locations from where you can start the MOTD script, for example, as ~/.bash_profile
, or /etc/profile.d/motd.sh
. More about autostarting scripts.
- Remove the default MOTD. It is located in
/etc/motd
.
$ sudo rm /etc/motd
- Remove the "last login" information from sshd. Disable the
PrintLastLog
option from thesshd
service. Edit the/etc/ssh/sshd_config
file and uncomment the line#PrintLastLog yes
:
$ sudo nano /etc/ssh/sshd_config
After:
PrintLastLog no
Restart the sshd
service:
$ sudo systemctl restart sshd
Note: If you don't see the degree Celsius character correctly (º
) make sure you have enabled a UTF8 locale (Arch Linux locales).
- If it doesn't exist already, create a
.bash_profile
file in your user's home directory
$ touch ~/.bash_profile
- Download or copy raw
pi-motd.sh
bash script to your new~/.bash_profile
using your favourite editor (e.g.vi
ornano
)