Pi-MOTD


My working dynamic Linux MOTD displayed when accessing device by SSH or terminal directly. Primarily designed for Raspberry Pi.

"Pi-MOTD in an SSH Terminal"

Credits

Thanks to others for advice and MOTD examples, including:

Compatibility

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.

Performance

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 :)

Installation

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.

  1. Remove the default MOTD. It is located in /etc/motd.
$ sudo rm /etc/motd
  1. Remove the "last login" information from sshd. Disable the PrintLastLog option from the sshd 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).

  1. If it doesn't exist already, create a .bash_profile file in your user's home directory
$ touch ~/.bash_profile
  1. Download or copy raw pi-motd.sh bash script to your new ~/.bash_profile using your favourite editor (e.g. vi or nano)