Secret Hacker Tip: Colorful Welcome Messages with Linux

Secret Hacker Tip: Colorful Welcome Messages with Linux

May 19, 2024
Get tips and best practices from Develeap’s experts in your inbox

Develeap — We can take you there!

Have you ever opened up a terminal window or initiated an SSH session and been welcomed by a cool-looking, colorful message? 

Today, we’re going to go through the steps to create our own!

The tools you need

In order to accomplish our goal, we are going to take advantage of 2 tools:

1 — Figlet

2 — Lolcat

FIGlet

FIGlet is a Free and open-source (FOSS) Terminal User Interface (TUI) application written in the C programming language. It is a program that creates large characters out of ordinary screen characters, similar to ASCII text art. FIGlet offers a variety of fonts and ships to multiple platforms.

Installation of figlet using Homebrew on MacOS is as simple as that:

brew install figlet

Lolcat

Similar to Figlet, lolcat is FOSS. It is a TUI application written using the ruby programming language with the sole purpose of

Rainbows and unicorns!

Taken from lolcat official github about section.

lolcat offers the ability to play with the spread as well as the frequency of rainbow, and also an animation option.

Installation of lolcat using Homebrew on MacOS is as simple as that:

brew install lolcat

Tie it all together

Next, we’ll use figlet together with lolcat to generate the our colorful message like so:

# Figlet flags in use:
# -c -> center output
# -f doh -> use the 'doh' font
# -w 250 -> set the output width to 250px
#
# '|' is used to pipe the out put from figlet and feed it into lolcat.
# ';' is used to indicate the end of the first execution, and the beginning of a new one.
figlet -c -f doh -w 250 "Develeap" | lolcat; figlet -c -f digital -w 250 'We Can Take Your There!' | lolcat

Setting the terminal message

Depending on the terminal you are using, setting the display message is quite easy. After working with the figlet and lolcat commands to get the desired output, all you have to do is append it to your terminal’s rc file. This file is used to configure your terminal’s settings.

In my case, I’m using zsh shell.

# Appending to the zshrc file as a oneline operation
echo "figlet -k -c -f doh -w 250 'Develeap.' | lolcat; figlet -k -c -f digital -w 250 'We Can Take Your There!' | lolcat" >> ~/.zshrc

# Reload to apply changes to current terminal session,
# Alternatively, start an new terminal window.
source ~/.zshrc

SSH login message

Similar to modifying the terminal message, changing the ssh login message requires modifying the SSH deamon configuration file.

Unfortunately, colors are not an option this time. Therefore, lolcat is discarded.


# Save a backup of the original file, or print a message if nonexistent
 cp /etc/issue /etc/issue.bak 2>/dev/null || echo "No file found"

# Create the banner file
figlet -k -c -f doh -w 250 "Develeap." > /etc/issue; figlet -k -c -f digital -w 250 'We Can Take Your There!' >> /etc/issue

# Set the sshd to use it.
echo "Banner /etc/issue" >> /etc/ssh/sshd_config

# Reload the SSH deamon to apply changes
sudo launchctl kickstart -k system/com.openssh.sshd

Bonus — SSH logout message

In the same manner we can set a custom logout message of an SSH session by editing the /etc/motd file.

That is it for this article, hope you enjoyed it.

We’re Hiring!
Develeap is looking for talented DevOps engineers who want to make a difference in the world.