Skip to content

Instantly share code, notes, and snippets.

@simbo
Last active February 23, 2024 11:00
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save simbo/dcc6740b9747ef1522c6f321843fa226 to your computer and use it in GitHub Desktop.
Save simbo/dcc6740b9747ef1522c6f321843fa226 to your computer and use it in GitHub Desktop.
Debian Linux SSH MOTD

Debian Linux (SSH) MOTD

The Message Of The Day displayed on shell login is generated from

  • output of executable scripts in /etc/update-motd.d
  • contents of /etc/motd
  • last ssh login

Custom Welcome Message

# create script for welcome message
cd /etc/update-motd.d
sudo touch 00-welcome
sudo chmod +x 00-welcome
sudo nano 00-welcome

# install toilet for ascii text display
sudo apt-get update
sudo apt-get install -y toilet

/etc/update-motd.d/00-welcome

#!/bin/bash

echo ""

# display ascii art with hostname
toilet --termwidth --filter border --gay --font future -k "$HOSTNAME"

echo ""

# display device model
echo "$(tr -d "\0" < /proc/device-tree/model)"

# display distribution name
echo "$(lsb_release -ds)"

# display kernel version
echo "$(uname -srm)"

echo ""

# display cpu/mem usage
cpuUsage=$(top -bn1 | awk '/Cpu/{printf "%d%%", $2}')
memUsage=$(free -m | awk '/Mem:/{printf "%.0f%% (%dM/%dM)", ($3/$2*100), $3, $2}')
echo "CPU Usage: $cpuUsage"
echo "Memory Usage: $memUsage"

# display disk usage
diskUsage="$(df -h --total | grep -E "^total")"
du=($diskUsage)
echo "Disk Usage: ${du[4]} (${du[2]}/${du[1]})"

echo ""

# display date and time
date "+%A, %e. %B %Y%n%T"

echo ""

Disable Displaying last SSH Login

Set PrintLastLog no in /etc/ssh/sshd_config.

Restart sshd with sudo systemctl restart ssh.service.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment