Introduction
In this quick article, I'll demonstrate how to add some color to your message of the day (MOTD) which is some text that is displayed on the screen when you first log in.We'll not be using the /etc/motd file for this so this file should be empty.
We'll create a script in /etc/profile.d/ that contains the text we'd like to print. Here I've named the script login-info.sh.
[ssuri@lab-node:~] $ cat /etc/profile.d/login-info.sh
#! /usr/bin/env bash
GREEN="\033[01;32m"
YELLOW="\033[01;33m"
MAGENTA="\033[01;35m"
CYAN="\033[01;36m"
NC="\033[00m"
echo -e "${GREEN}================================${NC}"
echo -e "${YELLOW}Welcome to the Ansible LAB Box${NC}"
echo -e "${GREEN}================================${NC}"
[ssuri@lab-node:~] $
I've used escape sequences with the echo command to display text in green and yellow colors when printed.
Next, we need to add the following line in /etc/ssh/sshd_config file and restart the sshd service.
PrintMotd no
That's it. The next time we login we'll be greeted with a colorful login message.